void SendPosRotUpdate(int id, unsigned short x, unsigned short y, int status, float rotation, int writesocket) { int stringsize = 10; unsigned char *buffer = malloc(stringsize); if (buffer == NULL) error_exit("Memory error ( SendPosRotUpdate() )\n"); int position = 0; unsigned short *px = &x; unsigned short *py = &y; //if(rotation > 180) rotation = (rotation - 360); //unsigned short *protation = &rotation; //2 Bytes cut off if (status == 0) buffer[position] = 14; else if (status == 1) buffer[position] = 13; position++; buffer[position] = id; position++; memcpy(buffer + position, px, 2); position += 2; memcpy(buffer + position, py, 2); position += 2; memcpy(buffer + position, &rotation, 4); position += 4; SendToAllOther(id, buffer, stringsize, 1, writesocket); free(buffer); }
void SendPosUpdate(int id, unsigned short x, unsigned short y, int status, int writesocket) { int stringsize = 6; unsigned char *buffer = malloc(stringsize); if (buffer == NULL) error_exit("Memory error ( SendSpawnMessage() )\n"); int position = 0; unsigned short *px = &x; unsigned short *py = &y; if (status == 0) buffer[position] = 11; else if (status == 1) buffer[position] = 10; position++; buffer[position] = id; position++; memcpy(buffer + position, px, 2); position += 2; memcpy(buffer + position, py, 2); position += 2; SendToAllOther(id, buffer, stringsize, 1, writesocket); free(buffer); }
//FIXME complete SendKillMessage void SendKillMessage(int id, int victim) { int suicide = 0; if (id == 0) {id = victim; suicide = 1;} byte sHealth[4]; byte sArmor[4]; //= player[id].health int sHealthLength = sprintf((char*)sHealth, "%i", (int) player[id].health); int sArmorLength = sprintf((char*)sArmor, "%i", (int) player[id].armor); int sNameLength = u_strlen(player[id].name); int length = 4 + sNameLength + sHealthLength + sArmorLength; stream* buf = init_stream(NULL); byte buffer[] = {19,victim,((suicide == 1) ? 0 : id), player[id].actualweapon, SHORT(*player[victim].x),SHORT(*player[victim].y), 240,0,1,SHORT(length),'k',166}; // 166 acts like a string separator, rest of this line is like wtf Stream.write(buf, buffer, 15); if (suicide == 0) { Stream.write(buf, player[id].name, sNameLength); Stream.write_byte(buf, 166); Stream.write(buf, sHealth, sHealthLength); Stream.write_byte(buf, 166); Stream.write(buf, sArmor, sArmorLength); Stream.write_byte(buf, 166); } SendToPlayer(buf->mem, buf->size, victim, 1); free(buf->mem); free(buf); byte buffer2[] = {19,victim,id,player[id].actualweapon,SHORT(*player[victim].x),SHORT(*player[victim].y)}; SendToAllOther(victim, buffer2, 8, 1); }
void SendRotUpdate(int id, float rotation, int writesocket) { int stringsize = 6; unsigned char *buffer = malloc(stringsize); if (buffer == NULL) error_exit("Memory error ( SendRotUpdate() )\n"); int position = 0; //if(rotation > 180) rotation = (rotation - 360); buffer[position] = 12; position++; buffer[position] = id; position++; memcpy(buffer + position, &rotation, sizeof(float)); SendToAllOther(id, buffer, stringsize, 1, writesocket); free(buffer); }
//FIXME complete SendKillMessage void SendKillMessage(int id, int victim, int writesocket) { char sHealth[4]; char sArmor[4]; //= player[id].health int sHealthLength = sprintf(sHealth, "%i", (int) player[id].health); int sArmorLength = sprintf(sArmor, "%i", (int) player[id].armor); int sNameLength = u_strlen(player[id].name); int length = 4 + sNameLength + sHealthLength + sArmorLength; // 4 for a6 spaces int stringsize = 17 + length; unsigned char *buffer = malloc(stringsize); if (buffer == NULL) error_exit("Memory error ( SendKillMessage() )\n"); int position = 0; buffer[position] = 19; position++; buffer[position] = victim; position++; buffer[position] = id; position++; buffer[position] = player[id].slot[player[id].actualweapon].id; position++; memcpy(buffer + position, &player[victim].x, 2); position += 2; memcpy(buffer + position, &player[victim].y, 2); position += 2; unsigned short unknown1 = 240; memcpy(buffer + position, &unknown1, 2); position += 2; buffer[position] = 1; position++; memcpy(buffer + position, &length, 2); position += 2; buffer[position] = 'k'; position++; buffer[position] = 166; //166 acts like string seperator position++; memcpy(buffer + position, player[id].name, sNameLength); position += sNameLength; buffer[position] = 166; position++; memcpy(buffer + position, &sHealth, sHealthLength); position += sHealthLength; buffer[position] = 166; position++; memcpy(buffer + position, &sArmor, sArmorLength); position += sArmorLength; SendToPlayer(buffer, stringsize, victim, 1, writesocket); free(buffer); stringsize = 8; buffer = malloc(stringsize); if (buffer == NULL) error_exit("Memory error ( SendKillMessage() )\n"); position = 0; buffer[position] = 19; position++; buffer[position] = victim; position++; buffer[position] = id; position++; buffer[position] = player[id].slot[player[id].actualweapon].id; position++; memcpy(buffer + position, &player[victim].x, 2); position += 2; memcpy(buffer + position, &player[victim].y, 2); position += 2; SendToAllOther(victim, buffer, stringsize, 1, writesocket); free(buffer); }
void SendRotUpdate(int id, float rotation){ byte buffer[] = {12,id,FLOAT(rotation)}; SendToAllOther(id, buffer, 6, 1); }
void SendPosRotUpdate(int id, unsigned short x, unsigned short y, int status,float rotation){ byte buffer[] = {status?13:14,id,SHORT(x),SHORT(y),FLOAT(rotation)}; SendToAllOther(id, buffer, 10, 1); }
void SendPosUpdate(int id, unsigned short x, unsigned short y, int status){ byte buffer[] = {status?10:11,id,SHORT(x),SHORT(y)}; SendToAllOther(id, buffer, 6, 1); }