int vote(PacketStream ps) { byte typ = ps.ReadByte(); string data = ps.ReadString(); botLogics.OnVote(data); return(1); }
int newname(PacketStream ps) { byte id = ps.ReadByte(); string new_name = ps.ReadString(); players[id].Name = new_name; return(1); }
int playerjoin(PacketStream ps) { byte id = ps.ReadByte(); PlayerObject temp = players[id]; temp.Name = ps.ReadString(); ps.ReadByte(); LogConsole(String.Format("[P] {0} connected!", temp.Name)); return(1); }
/// <summary> /// Function determines what happens when information about a server is returned /// </summary> /// <param name="ps"></param> /// <param name="svi"></param> /// <returns></returns> private int OnServerInformationReceive(PacketStream ps, ServerInformation svi) { byte cmd = ps.ReadByte(); if (cmd == 1) { ps.ReadByte(); // dunno? svi.Name = ps.ReadString(); svi.Map = ps.ReadString(); svi.CurrentClients = ps.ReadByte(); svi.MaxClients = ps.ReadByte(); byte gamemode = ps.ReadByte(); AddServerToGrid(svi); } else if (cmd == 5) { //player info } return(0); }
int chatmsg(PacketStream ps) { byte id = ps.ReadByte(); byte uk2 = ps.ReadByte(); byte strlen = ps.ReadByte(); ps.ReadByte(); string txt = ps.ReadString(strlen); if (id != 0 && players[id] != null) { LogConsole(String.Format("[P] {0}: {1}", players[id].Name, txt)); } else { LogConsole(String.Format("[U]: {0}", txt)); } return(1); }
/// <summary> /// Function determines what happens when information about a server is returned /// </summary> /// <param name="ps"></param> /// <param name="svi"></param> /// <returns></returns> private int OnServerInformationReceive(PacketStream ps,ServerInformation svi) { byte cmd = ps.ReadByte(); if (cmd == 1) { ps.ReadByte(); // dunno? svi.Name = ps.ReadString(); svi.Map = ps.ReadString(); svi.CurrentClients = ps.ReadByte(); svi.MaxClients = ps.ReadByte(); byte gamemode = ps.ReadByte(); AddServerToGrid(svi); } else if (cmd == 5) { //player info } return 0; }
int joinroutine_known(PacketStream ps) { int type2 = ps.ReadByte(); if (type2 == 0) { String serverKey = ps.ReadString(); send_join_packet_252_1(local_player, serverKey); } else if (type2 == 2) { byte state = ps.ReadByte(); if (state == 0) { own_id = ps.ReadByte(); String mapName = ps.ReadString(); String skey = ps.ReadString(); send_map_confirmation(mapName, skey); } else { if (state == 1) { LogConsole("Error: wrong password!"); } else if (state == 3) { LogConsole("Error: server is full!"); } else if (state == 4) { LogConsole("Error: banned!"); } else if (state == 23) { LogConsole("Error: maximum number of clients reached!"); } else if (state == 22) { LogConsole("Error: invalid precon send to server!"); } else { LogConsole("Error on joining: " + state); } cl.Close(); } } else if (type2 == 3) { } else if (type2 == 4) { ps.ReadByte(); send_map_name_252_05(); } else if (type2 == 6) { ps.SkipAll();//server data } else if (type2 == 7) { //Player data int type3 = ps.ReadByte(); if (type3 == 1) { int onlinePlayer = ps.ReadByte(); for (int i = 0; i < onlinePlayer; i++) { PlayerObject temp; byte id = ps.ReadByte(); temp = players[id]; temp.Id = id; temp.Name = StringHelper.DecodePlayerName(ps.ReadString()); string lulz = StringHelper.DecodePlayerName(ps.ReadString()); lulz += 'a'; //ps.ReadByte();//uk temp.Team = ps.ReadByte(); ps.ReadByte(); ps.ReadByte(); //uks temp.Score = ps.ReadShort(); temp.Death = ps.ReadShort(); temp.X = ps.ReadShort(); ps.ReadShort(); //uk tile_x temp.Y = ps.ReadShort(); ps.ReadShort(); // uk tile_y? ps.ReadShort(); // rotation?? temp.Health = ps.ReadByte(); temp.Armor = ps.ReadByte(); ps.ReadByte();//uk temp.Currentweapon = ps.ReadByte(); ps.ReadByte(); players[temp.Id] = temp; } LogConsole("Own player: " + players[own_id].ToString()); } else if (type3 == 2) { //hostage data ps.SkipAll(); } else if (type3 == 3) { // item data //ps.SkipAll(); int count = ps.ReadByte(); for (int i = 0; i < count; i++) { ps.ReadByte(); ps.ReadByte(); byte wpn_id = ps.ReadByte(); short tilex = ps.ReadShort(); short tiley = ps.ReadShort(); short ammoin = ps.ReadShort(); short ammo = ps.ReadShort(); botLogics.OnWeaponDrop(wpn_id, tilex, tiley, ammo, ammoin); } } else if (type3 == 4) //entity data { ps.SkipAll(); } else if (type3 == 5) //DynamicObjectData { ps.SkipAll(); } else if (type3 == 6) // ProjectileData { ps.SkipAll(); } else if (type3 == 7) //DynamicObjectImageData { ps.SkipAll(); } else if (type3 == 8) { ps.SkipAll(); } else if (type3 == 200) // final ack { LogConsole("Connected!"); ps.ReadString(); ps.ReadByte(); ps.ReadByte(); ps.ReadByte(); send_unknown_packet_28(); //send_spec_pos_32(440, 660); } } else if (type2 == 50) // okay wtf? { ps.SkipAll(); } return(1); }
int playerjoin(PacketStream ps) { byte id = ps.ReadByte(); PlayerObject temp = players[id]; temp.Name = ps.ReadString(); ps.ReadByte(); LogConsole(String.Format("[P] {0} connected!", temp.Name)); return 1; }
int newname(PacketStream ps) { byte id = ps.ReadByte(); string new_name = ps.ReadString(); players[id].Name = new_name; return 1; }
int joinroutine_known(PacketStream ps) { int type2 = ps.ReadByte(); if (type2 == 0) { String serverKey = ps.ReadString(); send_join_packet_252_1(local_player, serverKey); } else if (type2 == 2) { byte state = ps.ReadByte(); if (state == 0) { own_id = ps.ReadByte(); String mapName = ps.ReadString(); String skey = ps.ReadString(); send_map_confirmation(mapName, skey); } else { if (state == 1) LogConsole("Error: wrong password!"); else if (state == 3) LogConsole("Error: server is full!"); else if (state == 4) LogConsole("Error: banned!"); else if (state == 23) LogConsole("Error: maximum number of clients reached!"); else if (state == 22) LogConsole("Error: invalid precon send to server!"); else LogConsole("Error on joining: " + state); cl.Close(); } } else if (type2 == 3) { } else if (type2 == 4) { ps.ReadByte(); send_map_name_252_05(); } else if (type2 == 6) { ps.SkipAll();//server data } else if (type2 == 7) { //Player data int type3 = ps.ReadByte(); if (type3 == 1) { int onlinePlayer = ps.ReadByte(); for (int i = 0; i < onlinePlayer; i++) { PlayerObject temp; byte id = ps.ReadByte(); temp = players[id]; temp.Id = id; temp.Name = StringHelper.DecodePlayerName(ps.ReadString()); string lulz = StringHelper.DecodePlayerName(ps.ReadString()); lulz += 'a'; //ps.ReadByte();//uk temp.Team = ps.ReadByte(); ps.ReadByte(); ps.ReadByte(); //uks temp.Score = ps.ReadShort(); temp.Death = ps.ReadShort(); temp.X = ps.ReadShort(); ps.ReadShort();//uk tile_x temp.Y = ps.ReadShort(); ps.ReadShort(); // uk tile_y? ps.ReadShort();// rotation?? temp.Health = ps.ReadByte(); temp.Armor = ps.ReadByte(); ps.ReadByte();//uk temp.Currentweapon = ps.ReadByte(); ps.ReadByte(); players[temp.Id] = temp; } LogConsole("Own player: " + players[own_id].ToString()); } else if (type3 == 2) { //hostage data ps.SkipAll(); } else if (type3 == 3) { // item data //ps.SkipAll(); int count = ps.ReadByte(); for (int i = 0; i < count; i++) { ps.ReadByte(); ps.ReadByte(); byte wpn_id = ps.ReadByte(); short tilex = ps.ReadShort(); short tiley = ps.ReadShort(); short ammoin = ps.ReadShort(); short ammo = ps.ReadShort(); botLogics.OnWeaponDrop(wpn_id, tilex, tiley, ammo, ammoin); } } else if (type3 == 4) //entity data { ps.SkipAll(); } else if (type3 == 5) //DynamicObjectData { ps.SkipAll(); } else if (type3 == 6) // ProjectileData { ps.SkipAll(); } else if (type3 == 7) //DynamicObjectImageData { ps.SkipAll(); } else if (type3 == 8) { ps.SkipAll(); } else if (type3 == 200) // final ack { LogConsole("Connected!"); ps.ReadString(); ps.ReadByte(); ps.ReadByte(); ps.ReadByte(); send_unknown_packet_28(); //send_spec_pos_32(440, 660); } } else if (type2 == 50) // okay wtf? ps.SkipAll(); return 1; }
int chatmsg(PacketStream ps) { byte id = ps.ReadByte(); byte uk2 = ps.ReadByte(); byte strlen = ps.ReadByte(); ps.ReadByte(); string txt = ps.ReadString(strlen); if (id != 0 && players[id] != null) LogConsole(String.Format("[P] {0}: {1}", players[id].Name, txt)); else LogConsole(String.Format("[U]: {0}", txt)); return 1; }
int vote(PacketStream ps) { byte typ = ps.ReadByte(); string data = ps.ReadString(); botLogics.OnVote(data); return 1; }