shits dynamic and cool now.

This commit is contained in:
Wirlaburla 2023-09-24 01:41:00 -05:00
parent 51572fef98
commit 3b9b668c2b
3 changed files with 109 additions and 101 deletions

View File

@ -18,14 +18,15 @@ int roomsock;
std::thread aRecv_t; std::thread aRecv_t;
std::thread rRecv_t; std::thread rRecv_t;
std::thread rKA_t; std::thread rKeepAlive_t;
char* worldsserver = "209.240.84.122"; uint8_t autoserver[4] = { 209, 240, 84, 122 };
uint16_t autoport = 6650; uint16_t autoport = 6650;
uint8_t roomserver[4] = { 209, 240, 84, 122 };
uint16_t roomport = 5672; uint16_t roomport = 5672;
int protocol = 24; int protocol = 24;
char* version = "0000000000"; char* version = "1000000000";
char* avatar = "avatar:pengo.mov"; char* avatar = "avatar:pengo.mov";
int avatars = 253; int avatars = 253;
char* room = "GroundZero#Reception"; char* room = "GroundZero#Reception";
@ -42,28 +43,28 @@ uint16_t rot = 0;
std::map<char, char*> properties; std::map<char, char*> properties;
std::map<char, Drone> objects; std::map<char, Drone> objects;
std::map<char*, uint16_t> rooms;
std::vector<char*> friends; std::vector<char*> friends;
std::vector<char*> mutes; std::vector<char*> mutes;
int deinit(int response);
static char* trim(char *str); static char* trim(char *str);
char* zero(int size); char* zero(int size);
unsigned char* uzero(int size); unsigned char* uzero(int size);
void autoInit(); void autoInit();
void roomInit(); void roomInit();
void roomKeepAlive(); void roomKeepAlive();
void reciever(int sock_fd, bool autoserver); void reciever(int *sock, uint16_t port);
void sessInit(int sock_fd, char* username, char* password); void sessInit(int *sock, char* username, char* password);
void sessExit(int sock_fd); void sessExit(int *sock);
void readPropertyList(unsigned char* in); void readPropertyList(unsigned char* in);
std::map<char, char*> readOldPropertyList(unsigned char* in); std::map<char, char*> readOldPropertyList(unsigned char* in);
void setAvatar(int sock_fd, char* avatar); void setAvatar(int *sock, char* avatar);
void roomIDReq(int sock_fd, char* room); void roomIDReq(int *sock, char* room);
void teleport(int sock_fd, int x, int y, int z, int rot); void teleport(int *sock, int x, int y, int z, int rot);
char* dimAdd(char* room); char* dimAdd(char* room);
void userEnter(char id); void userEnter(char id);
void userExit(char id); void userExit(char id);
int wsend(int sock_fd, unsigned char str[], int flags); int wsend(int *sock, unsigned char str[], int flags);
#endif #endif

View File

@ -30,19 +30,10 @@ static char* trim(char *str) {
*(end+1) = '\0'; *(end+1) = '\0';
return str; return str;
} }
struct sockaddr_in auto_addr;
struct sockaddr_in room_addr;
int main(int argc, char const* argv[]) { int main(int argc, char const* argv[]) {
unsigned char bufout[BUFFERSIZE] = {0}; unsigned char bufout[BUFFERSIZE] = {0};
auto_addr.sin_family = AF_INET;
inet_pton(AF_INET, worldsserver, &auto_addr.sin_addr);
auto_addr.sin_port = htons(autoport);
room_addr.sin_family = AF_INET;
inet_pton(AF_INET, worldsserver, &room_addr.sin_addr);
room_addr.sin_port = htons(roomport);
initscr(); initscr();
cbreak(); cbreak();
noecho(); noecho();
@ -127,7 +118,7 @@ int main(int argc, char const* argv[]) {
autoInit(); autoInit();
} else if (strcmp(cmd, "disconnect") == 0) { } else if (strcmp(cmd, "disconnect") == 0) {
if (aRecv_t.joinable()) aRecv_t.detach(); if (aRecv_t.joinable()) aRecv_t.detach();
wsend(autosock, new unsigned char[] {0x03, 0x01, CMD_SESSEXIT}, 0); wsend(&autosock, new unsigned char[] {0x03, 0x01, CMD_SESSEXIT}, 0);
} else if (strcmp(cmd, "login") == 0) { } else if (strcmp(cmd, "login") == 0) {
char username[32] = {0}; j = 0; char username[32] = {0}; j = 0;
while (msgoff < msglen && (s = inmsg[msgoff++]) != 0x20) { while (msgoff < msglen && (s = inmsg[msgoff++]) != 0x20) {
@ -150,7 +141,7 @@ int main(int argc, char const* argv[]) {
login_password[p] = password[p]; login_password[p] = password[p];
login_password[p]; login_password[p];
wprintw(wlog, "\n*Logging in as %s.", username); wprintw(wlog, "\n*Logging in as %s.", username);
sessInit(autosock, username, password); sessInit(&autosock, username, password);
} else if ((strcmp(cmd, "w") == 0 || strcmp(cmd, "whisper") == 0) && srcLine < 0) { } else if ((strcmp(cmd, "w") == 0 || strcmp(cmd, "whisper") == 0) && srcLine < 0) {
int k = 1; int k = 1;
bufout[k++] = 0; bufout[k++] = 0;
@ -178,7 +169,7 @@ int main(int argc, char const* argv[]) {
bufout[k] = 0; bufout[k] = 0;
bufout[0] = k; bufout[0] = k;
wprintw(wlog, "\n <- [%s] %s", username, message); wprintw(wlog, "\n <- [%s] %s", username, message);
wsend(roomsock, bufout, 0); wsend(&roomsock, bufout, 0);
} else if (strcmp(cmd, "f") == 0 || strcmp(cmd, "friends") == 0) { } else if (strcmp(cmd, "f") == 0 || strcmp(cmd, "friends") == 0) {
char subcmd[4] = {0}; j = 0; char subcmd[4] = {0}; j = 0;
@ -213,7 +204,7 @@ int main(int argc, char const* argv[]) {
bufout[k++] = 0x01; bufout[k++] = 0x01;
bufout[k] = 0; bufout[k] = 0;
wprintw(wlog, "\n*%s added to friendslist.", username); wprintw(wlog, "\n*%s added to friendslist.", username);
wsend(roomsock, bufout, 0); wsend(&roomsock, bufout, 0);
} else { } else {
wprintw(wlog, "\n*%s is already your friend!", username); wprintw(wlog, "\n*%s is already your friend!", username);
} }
@ -243,14 +234,14 @@ int main(int argc, char const* argv[]) {
bufout[k++] = 0x00; bufout[k++] = 0x00;
bufout[k] = 0; bufout[k] = 0;
wprintw(wlog, "\n*%s removed from friendslist.", username); wprintw(wlog, "\n*%s removed from friendslist.", username);
wsend(roomsock, bufout, 0); wsend(&roomsock, bufout, 0);
} else { } else {
wprintw(wlog, "\n*%s isn't on your friendslist.", username); wprintw(wlog, "\n*%s isn't on your friendslist.", username);
} }
} else if (strcmp(subcmd, "list") == 0) { } else if (strcmp(subcmd, "list") == 0) {
wprintw(wlog, "\n*Friendslist:"); wprintw(wlog, "\n*Friendslist:");
for (std::vector<char*>::iterator v = friends.begin(); v != friends.end(); ++v) for (std::vector<char*>::iterator v = friends.begin(); v != friends.end(); ++v)
wprintw(wlog, "%s %s", v==friends.begin()?",":"", *v); wprintw(wlog, "%s %s", v!=friends.begin()?",":"", *v);
} else { } else {
wprintw(wlog, "\n.friend <add|del|list> [user]"); wprintw(wlog, "\n.friend <add|del|list> [user]");
} }
@ -304,7 +295,7 @@ int main(int argc, char const* argv[]) {
} else if (strcmp(subcmd, "list") == 0) { } else if (strcmp(subcmd, "list") == 0) {
wprintw(wlog, "\n*Mutelist:"); wprintw(wlog, "\n*Mutelist:");
for (std::vector<char*>::iterator v = mutes.begin(); v != mutes.end(); ++v) for (std::vector<char*>::iterator v = mutes.begin(); v != mutes.end(); ++v)
wprintw(wlog, "%s %s", v==mutes.begin()?",":"", *v); wprintw(wlog, "%s %s", v!=mutes.begin()?",":"", *v);
} else { } else {
wprintw(wlog, "\n.mute <add|del|list> [user]"); wprintw(wlog, "\n.mute <add|del|list> [user]");
} }
@ -316,7 +307,7 @@ int main(int argc, char const* argv[]) {
avatar[j] = 0; avatar[j] = 0;
if (strlen(avatar) == 0) { wprintw(wlog, "\n*.avatar <URI>"); continue; } if (strlen(avatar) == 0) { wprintw(wlog, "\n*.avatar <URI>"); continue; }
wprintw(wlog, "\n*Avatar set to: %s", avatar); wprintw(wlog, "\n*Avatar set to: %s", avatar);
setAvatar(roomsock, avatar); setAvatar(&roomsock, avatar);
} else if (strcmp(cmd, "teleport") == 0) { } else if (strcmp(cmd, "teleport") == 0) {
char _x[6] = {0}; int j = 0; char _x[6] = {0}; int j = 0;
while (msgoff < msglen && (s = inmsg[msgoff++]) != 0x20) { while (msgoff < msglen && (s = inmsg[msgoff++]) != 0x20) {
@ -353,12 +344,12 @@ int main(int argc, char const* argv[]) {
} }
_room[j] = 0; _room[j] = 0;
if (strlen(_room) == 0) { if (strlen(_room) == 0) {
teleport(roomsock, xPos, yPos, zPos, rot); teleport(&roomsock, xPos, yPos, zPos, rot);
wprintw(wlog, "\n*Teleported to [%u,%u,%u,%u]", xPos, yPos, zPos, rot); wprintw(wlog, "\n*Teleported to [%u,%u,%u,%u]", xPos, yPos, zPos, rot);
} else { } else {
room = _room; room = _room;
wprintw(wlog, "\n*Teleporting to %s [%u,%u,%u,%u]", room, xPos, yPos, zPos, rot); wprintw(wlog, "\n*Teleporting to %s [%u,%u,%u,%u]", room, xPos, yPos, zPos, rot);
roomIDReq(roomsock, room); roomIDReq(&roomsock, room);
} }
} else if (strcmp(cmd, "dimension") == 0) { } else if (strcmp(cmd, "dimension") == 0) {
char dim[32] = {0}; int j = 0; char dim[32] = {0}; int j = 0;
@ -369,7 +360,7 @@ int main(int argc, char const* argv[]) {
if (strlen(dim) == 0) { wprintw(wlog, "\n*.dimension <TEXT>"); continue; } if (strlen(dim) == 0) { wprintw(wlog, "\n*.dimension <TEXT>"); continue; }
wprintw(wlog, "\n*Changing dimension: %s", dim); wprintw(wlog, "\n*Changing dimension: %s", dim);
dimension = dim; dimension = dim;
roomIDReq(roomsock, room); roomIDReq(&roomsock, room);
} else if (strcmp(cmd, "clear") == 0) { } else if (strcmp(cmd, "clear") == 0) {
wclear(wlog); wclear(wlog);
wmove(wlog, LINES-2, 0); wmove(wlog, LINES-2, 0);
@ -381,10 +372,9 @@ int main(int argc, char const* argv[]) {
_f=true; _f=true;
} }
} else if (strcmp(cmd, "logout") == 0) { } else if (strcmp(cmd, "logout") == 0) {
wsend(autosock, new unsigned char[] {0x03, 0x01, CMD_SESSEXIT}, 0); sessExit(&roomsock); sessExit(&autosock);
wsend(roomsock, new unsigned char[] {0x03, 0x01, CMD_SESSEXIT}, 0);
} else if (strcmp(cmd, "q") == 0) { } else if (strcmp(cmd, "q") == 0) {
goto quit; return deinit(0);
} else { } else {
wprintw(wlog, "\n*Unknown command: \"%s\"", cmd); wprintw(wlog, "\n*Unknown command: \"%s\"", cmd);
} }
@ -408,7 +398,7 @@ int main(int argc, char const* argv[]) {
bufout[k++] = inmsg[l]; bufout[k++] = inmsg[l];
bufout[k] = 0; bufout[k] = 0;
bufout[0] = k; bufout[0] = k;
wsend(roomsock, bufout, 0); wsend(&roomsock, bufout, 0);
} }
bufout[0] = 0; bufout[0] = 0;
} }
@ -432,16 +422,38 @@ int main(int argc, char const* argv[]) {
wrefresh(wlog); wrefresh(wlog);
refresh(); refresh();
} }
quit:
unpost_form(form); unpost_form(form);
free_form(form); free_form(form);
free_field(entries[0]); free_field(entries[0]);
endwin(); endwin();
close(roomsock); close(roomsock);
return 0; return deinit(0);
}
int deinit(int response) {
if (netstatus) {
sessExit(&roomsock);
sessExit(&autosock);
}
if (aRecv_t.joinable()) aRecv_t.detach();
if (rRecv_t.joinable()) rRecv_t.detach();
if (rKeepAlive_t.joinable()) rKeepAlive_t.detach();
unpost_form(form);
free_form(form);
free_field(entries[0]);
endwin();
close(autosock);
close(roomsock);
return response;
} }
void autoInit() { void autoInit() {
if (aRecv_t.joinable()) aRecv_t.detach();
sockaddr_in auto_addr;
auto_addr.sin_family = AF_INET;
memcpy((void*)&auto_addr.sin_addr.s_addr, (void*)&autoserver, sizeof(roomserver));
auto_addr.sin_port = htons(autoport);
if ((autosock = socket(AF_INET, SOCK_STREAM, 0)) < 0) if ((autosock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
perror("AutoSock creation error"); perror("AutoSock creation error");
@ -449,39 +461,46 @@ void autoInit() {
if (connect(autosock, (struct sockaddr*)&auto_addr, sizeof(auto_addr)) < 0) if (connect(autosock, (struct sockaddr*)&auto_addr, sizeof(auto_addr)) < 0)
perror("AutoServ connection failed"); perror("AutoServ connection failed");
wprintw(wlog, "\n*Connected to AutoServer %s:%i", worldsserver, autoport); wprintw(wlog, "\n*Connected to AutoServer: %i.%i.%i.%i:%i", autoserver[1], autoserver[1], autoserver[2], autoserver[3], autoport);
// Initialize connection. aRecv_t = std::thread(reciever, &autosock, autoport);
aRecv_t = std::thread(reciever, autosock, true); wsend(&autosock, new unsigned char[] {0x03, 0xff, CMD_PROPREQ}, 0);
wsend(autosock, new unsigned char[] {0x03, 0xff, CMD_PROPREQ}, 0);
wrefresh(wlog); wrefresh(wlog);
netstatus = true; netstatus = true;
} }
void roomInit() { void roomInit() {
if (rRecv_t.joinable()) rRecv_t.detach();
if (rKeepAlive_t.joinable()) rKeepAlive_t.detach();
sockaddr_in room_addr;
room_addr.sin_family = AF_INET;
memcpy((void*)&room_addr.sin_addr.s_addr, (void*)&roomserver, sizeof(roomserver));
room_addr.sin_port = htons(roomport);
if ((roomsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) if ((roomsock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
perror("AutoSock creation error"); perror("AutoSock creation error");
if ((connect(roomsock, (struct sockaddr*)&room_addr, sizeof(room_addr))) < 0) if ((connect(roomsock, (struct sockaddr*)&room_addr, sizeof(room_addr))) < 0)
perror("RoomServ connection failed"); perror("RoomServ connection failed");
wprintw(wlog, "\n*Connected to RoomServer %s:%i", worldsserver, roomport);
rRecv_t = std::thread(reciever, roomsock, false); wsend(&autosock, new unsigned char[] {0x03, 0xff, CMD_PROPREQ}, 0);
rKA_t = std::thread(roomKeepAlive); wprintw(wlog, "\n*Connected to RoomServer: %i.%i.%i.%i:%i", roomserver[1], roomserver[1], roomserver[2], roomserver[3], roomport);
sessInit(roomsock, login_username, login_password); rRecv_t = std::thread(reciever, &roomsock, roomport);
login_password[0] = 0; rKeepAlive_t = std::thread(roomKeepAlive);
sessInit(&roomsock, login_username, login_password);
wrefresh(wlog); wrefresh(wlog);
} }
void roomKeepAlive() { void roomKeepAlive() {
while (netstatus) { while (netstatus) {
teleport(roomsock, xPos, yPos, zPos, rot); teleport(&roomsock, xPos, yPos, zPos, rot);
sleep(5); sleep(5);
} }
} }
void reciever(int sock_fd, bool autoserver = false) { void reciever(int *sock, uint16_t port) {
unsigned char bufin[BUFFERSIZE] = {}; unsigned char bufin[BUFFERSIZE] = {};
unsigned char bufout[BUFFERSIZE] = {}; unsigned char bufout[BUFFERSIZE] = {};
while (read(sock_fd, bufin, sizeof(bufin)) > 0) { while (read(*sock, bufin, sizeof(bufin)) > 0) {
int p = 0; int p = 0;
more_in_buffer: more_in_buffer:
int buflen = bufin[p]; int buflen = bufin[p];
@ -550,22 +569,21 @@ void reciever(int sock_fd, bool autoserver = false) {
objects[shortID] = newDrone; objects[shortID] = newDrone;
} }
} else if (bufin[p+2] == CMD_SESSEXIT && bufin[p+1] == 0x01) { } else if (bufin[p+2] == CMD_SESSEXIT && bufin[p+1] == 0x01) {
close(sock_fd); close(*sock);
if (autoserver) { if (port == autoport) {
wprintw(wlog, "\n*Logged out of %s.", login_username); wprintw(wlog, "\n*Logged out of %s.", login_username);
memset(&(login_password[0]), 0, sizeof(login_password));
// Clear // Clear
properties.erase(properties.begin(), properties.end()); properties.erase(properties.begin(), properties.end());
objects.erase(objects.begin(), objects.end()); objects.erase(objects.begin(), objects.end());
rooms.erase(rooms.begin(), rooms.end());
friends.clear(); friends.clear();
mutes.clear(); mutes.clear();
autosock = -1;
aRecv_t.detach(); aRecv_t.detach();
netstatus = false; netstatus = false;
wprintw(wlog, "\n*Disconnected!", sock_fd); wprintw(wlog, "\n*Disconnected!");
} else { } else if (port == roomport) {
wprintw(wlog, "\n*Leaving room %s<%s>", room, dimension); wprintw(wlog, "\n*Leaving room %s<%s>", room, dimension);
roomID = 1; roomID = 1;
room = "GroundZero#Reception"; room = "GroundZero#Reception";
@ -574,9 +592,6 @@ void reciever(int sock_fd, bool autoserver = false) {
yPos = 0; yPos = 0;
zPos = 0; zPos = 0;
rot = 0; rot = 0;
rRecv_t.detach();
rKA_t.detach();
} }
} else if (bufin[p+2] == CMD_SESSINIT && bufin[p+1] == 0x01) { } else if (bufin[p+2] == CMD_SESSINIT && bufin[p+1] == 0x01) {
std::map<char, char*> props = readOldPropertyList(&bufin[p]); std::map<char, char*> props = readOldPropertyList(&bufin[p]);
@ -602,19 +617,16 @@ void reciever(int sock_fd, bool autoserver = false) {
} }
wprintw(wlog, "\n*Error %i: %s", err, errMsg); wprintw(wlog, "\n*Error %i: %s", err, errMsg);
if (autoserver) { if (port == autoport) {
aRecv_t.detach();
netstatus = false; netstatus = false;
} else { } else {
rRecv_t.detach();
rKA_t.detach();
} }
} else { } else {
if (!autoserver) { if (port != autoport) {
memset(&(login_password[0]), 0, sizeof(login_password)); setAvatar(sock, avatar);
setAvatar(sock_fd, avatar);
} else { } else {
roomIDReq(sock_fd, room); roomIDReq(sock, room);
} }
} }
} else if ((bufin[p+2] == CMD_ROOMID || bufin[p+2] == 0x1A) && bufin[p+1] == 0x01) { } else if ((bufin[p+2] == CMD_ROOMID || bufin[p+2] == 0x1A) && bufin[p+1] == 0x01) {
@ -626,14 +638,14 @@ void reciever(int sock_fd, bool autoserver = false) {
longID[long_len+1] = 0; longID[long_len+1] = 0;
offs+=long_len; offs+=long_len;
shortID = ((uint16_t)bufin[offs++] << 8) | bufin[offs++]; shortID = ((uint16_t)bufin[offs++] << 8) | bufin[offs++];
rooms[longID] = shortID;
roomID = shortID; roomID = shortID;
if (autoserver) roomInit(); memcpy(&roomserver, new uint8_t[4]{ bufin[offs++], bufin[offs++], bufin[offs++], bufin[offs++] }, 4);
roomport = (bufin[offs++] << 8) | bufin[offs++];
if (port != autoport) sessExit(sock);
wprintw(wlog, "\n*Joining room %s", longID); wprintw(wlog, "\n*Joining room %s", longID);
for (const auto& [key, value] : objects) { objects.erase(objects.begin(), objects.end());
objects.erase((char)key); roomInit();
} teleport(sock, xPos, yPos, zPos, rot);
teleport(sock_fd, xPos, yPos, zPos, rot);
} else if (bufin[p+2] == CMD_BUDDYNTF && bufin[p+1] == 0x01) { } else if (bufin[p+2] == CMD_BUDDYNTF && bufin[p+1] == 0x01) {
char* username = new char[32]; char* username = new char[32];
int offs = p+3; int offs = p+3;
@ -675,7 +687,7 @@ void reciever(int sock_fd, bool autoserver = false) {
wrefresh(wlog); wrefresh(wlog);
} }
void sessInit(int sock_fd, char* name, char* pass) { void sessInit(int *sock, char* name, char* pass) {
unsigned char bufout[BUFFERSIZE] = {0}; unsigned char bufout[BUFFERSIZE] = {0};
bufout[1] = 0x01; bufout[1] = 0x01;
bufout[2] = CMD_SESSINIT; bufout[2] = CMD_SESSINIT;
@ -722,15 +734,15 @@ void sessInit(int sock_fd, char* name, char* pass) {
bufout[0] = l; bufout[0] = l;
bufout[l+1] = 0; bufout[l+1] = 0;
wsend(sock_fd, bufout, 0); wsend(sock, bufout, 0);
} }
void sessExit(int sock_fd) { void sessExit(int *sock) {
unsigned char bufout[BUFFERSIZE] = {0}; unsigned char bufout[BUFFERSIZE] = {0};
bufout[0] = 0x03; bufout[0] = 0x03;
bufout[1] = 0x01; bufout[1] = 0x01;
bufout[2] = CMD_SESSEXIT; bufout[2] = CMD_SESSEXIT;
wsend(sock_fd, bufout, 0); wsend(sock, bufout, 0);
} }
void constructPropertyList(int type, std::map<int, char*> props, unsigned char* snd) { void constructPropertyList(int type, std::map<int, char*> props, unsigned char* snd) {
@ -792,7 +804,7 @@ void readPropertyList(unsigned char* in) {
} }
*/ */
void setAvatar(int sock_fd, char* avatar) { void setAvatar(int *sock, char* avatar) {
unsigned char bufav[BUFFERSIZE] = {0}; unsigned char bufav[BUFFERSIZE] = {0};
int l = 1; int l = 1;
bufav[l++] = 0x01; bufav[l++] = 0x01;
@ -808,29 +820,24 @@ void setAvatar(int sock_fd, char* avatar) {
bufav[0] = l; bufav[0] = l;
bufav[l+1] = 0; bufav[l+1] = 0;
wsend(sock_fd, bufav, 0); wsend(sock, bufav, 0);
} }
void roomIDReq(int sock_fd, char* room) { void roomIDReq(int *sock, char* room) {
char* fullRoom = dimAdd(room); char* fullRoom = dimAdd(room);
// Don't do this, rooms with new IDs won't update. unsigned char bufrm[BUFFERSIZE] = {0};
//if (rooms.find(fullRoom) != rooms.end()) { bufrm[1] = 1;
// roomID = rooms[fullRoom]; bufrm[2] = CMD_ROOMIDREQ;
//} else { bufrm[3] = strlen(fullRoom);
unsigned char bufrm[BUFFERSIZE] = {0}; int x = 4;
bufrm[1] = 1; for (int z = 0; z < strlen(fullRoom); z++)
bufrm[2] = CMD_ROOMIDREQ; bufrm[x++] = fullRoom[z];
bufrm[3] = strlen(fullRoom); bufrm[x++] = 0;
int x = 4; bufrm[0] = x;
for (int z = 0; z < strlen(fullRoom); z++) wsend(sock, bufrm, 0);
bufrm[x++] = fullRoom[z];
bufrm[x++] = 0;
bufrm[0] = x;
wsend(sock_fd, bufrm, 0);
//}
} }
void teleport(int sock_fd, int x, int y, int z, int rot) { void teleport(int *sock, int x, int y, int z, int rot) {
unsigned char buftp[16] = {0}; unsigned char buftp[16] = {0};
uint8_t _roomID[2]; uint8_t _roomID[2];
uint8_t _x[2]; uint8_t _x[2];
@ -853,7 +860,7 @@ void teleport(int sock_fd, int x, int y, int z, int rot) {
buftp[12] = _z[0]; buftp[11] = _z[1]; buftp[12] = _z[0]; buftp[11] = _z[1];
buftp[14] = _rot[0]; buftp[13] = _rot[1]; buftp[14] = _rot[0]; buftp[13] = _rot[1];
wsend(sock_fd, buftp, 0); wsend(sock, buftp, 0);
} }
char* dimAdd(char* room) { char* dimAdd(char* room) {
@ -883,6 +890,6 @@ void userExit(char id) {
} }
} }
int wsend(int sock_fd, unsigned char str[], int flags) { int wsend(int *sock, unsigned char str[], int flags) {
return send(sock_fd, str, str[0], flags); return send(*sock, str, str[0], flags);
} }

View File

@ -16,7 +16,7 @@
#define VAR_BAD_ACCOUNT 14 #define VAR_BAD_ACCOUNT 14
#define VAR_NOT_LOGGEDON 15 #define VAR_NOT_LOGGEDON 15
#define VAR_BAD_IPADDRESS 16 #define VAR_BAD_IPADDRESS 16
#define VAR_LOGGEDON 16 #define VAR_LOGGEDON 17
#define VAR_ROOM_FULL 21 #define VAR_ROOM_FULL 21
#define VAR_UNEXPECTED 100 | 101 | 102 | 103 #define VAR_UNEXPECTED 100 | 101 | 102 | 103
#define VAR_UNREACHABLE 104 | 105 | 106 | 107 #define VAR_UNREACHABLE 104 | 105 | 106 | 107