/** Describe the socket we opened to the LDAP server * * @param[in] listen abstracting the connection to the server. * @param[out] buffer Where to write text describing the socket. * @param[in] bufsize the length of data written to buffe.r * @return 1. */ static int proto_ldap_socket_print(rad_listen_t const *listen, char *buffer, size_t bufsize) { size_t len; proto_ldap_inst_t *inst = listen->data; char const *name = listen->proto->name; #define FORWARD len = strlen(buffer); if (len >= (bufsize + 1)) return 0;buffer += len;bufsize -= len #define ADDSTRING(_x) strlcpy(buffer, _x, bufsize);FORWARD ADDSTRING(name); ADDSTRING(" server "); fr_inet_ntoh(&inst->dst_ipaddr, buffer, bufsize); FORWARD; ADDSTRING(" port "); snprintf(buffer, bufsize, "%d", inst->dst_port); FORWARD; if (listen->server) { ADDSTRING(" bound to virtual-server "); strlcpy(buffer, listen->server, bufsize); } #undef ADDSTRING #undef FORWARD return 1; }
// Messenger Chat bool CCharServer::pakMessengerChat ( CCharClient* thisclient, CPacket* P ) { WORD id = GETWORD((*P),0); char* message = new char[P->Size-41]; if(message==NULL) { Log(MSG_ERROR, "Error allocing memory: pakMessengerChat" ); return false; } memcpy( message, &P->Buffer[35], P->Size-41 ); CCharClient* otherclient = (CCharClient*) GetClientByID(id); if(otherclient!=NULL) { BEGINPACKET( pak, 0x7e2 ); ADDWORD ( pak, thisclient->charid ); ADDWORD ( pak, 0x0000 ); ADDSTRING ( pak, thisclient->charname ); UINT namesize = strlen(thisclient->charname); for (int i=0;i<30-namesize;i++) ADDBYTE ( pak, 0x00 ); ADDBYTE ( pak, 0x00 ); ADDSTRING ( pak, message ); ADDBYTE ( pak, 0x00 ); otherclient->SendPacket(&pak); } delete []message; return true; }
char* ConstructChildProcessArgs(const CommandLine::Options& o) { int bytesWritten = 0; char* spmiArgs = new char[MAX_CMDLINE_SIZE]; *spmiArgs = '\0'; // We don't pass through /parallel, /skipCleanup, /verbosity, /failingMCList, or /diffMCList. Everything else we need to reconstruct and pass through. #define ADDSTRING(s) if (s != nullptr) { bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " %s", s); } #define ADDARG_BOOL(b,arg) if (b) { bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " %s", arg); } #define ADDARG_STRING(s,arg) if (s != nullptr) { bytesWritten += sprintf_s(spmiArgs + bytesWritten, MAX_CMDLINE_SIZE - bytesWritten, " %s %s", arg, s); } ADDARG_BOOL(o.breakOnError, "-boe"); ADDARG_BOOL(o.breakOnAssert, "-boa"); ADDARG_BOOL(o.applyDiff, "-applyDiff"); ADDARG_STRING(o.reproName, "-reproName"); ADDARG_STRING(o.writeLogFile, "-writeLogFile"); ADDARG_STRING(o.methodStatsTypes, "-emitMethodStats"); ADDARG_STRING(o.reproName, "-reproName"); ADDARG_STRING(o.hash, "-matchHash"); ADDARG_STRING(o.targetArchitecture, "-target"); ADDARG_STRING(o.compileList, "-compile"); ADDSTRING(o.nameOfJit); ADDSTRING(o.nameOfJit2); ADDSTRING(o.nameOfInputMethodContextFile); #undef ADDSTRING #undef ADDARG_BOOL #undef ADDARG_STRING return spmiArgs; }
void CMap::UpdateArena( CPlayer* thisclient ) { if(thisclient== NULL || thisclient->Groupga->Groupga == NULL) return; GAGroup* thisgroup = thisclient->Groupga->Groupga; int fragments = -1; for( UINT i=0; i< MonsterList.size();i++) { CMonster* thismon = MonsterList.at(i); if(thismon->team == thisgroup->GroupId && thismon->montype == 3708) fragments++; } Log(MSG_INFO,"called updatearena fragments = %i",fragments); if(fragments == 7) { for(UINT i=0;i<NPCList.size();i++) { CNPC* thisnpc = NPCList.at(i); if(thisnpc->thisnpc->id == 3704 && thisnpc->pos.x > 5160 && thisnpc->pos.x < 5170 && thisnpc->pos.y > 4915 && thisnpc->pos.y < 4925 && thisnpc->team == thisgroup->GroupId) { Log(MSG_INFO,"remove wall"); DeleteNPC(thisnpc); BEGINPACKET( pak, 0x794 ); ADDWORD( pak, thisnpc->clientid ); GServer->SendToVisible( &pak, thisclient ); RESETPACKET( pak, 0x799 ); ADDWORD ( pak, thisnpc->clientid ); ADDWORD ( pak, thisnpc->clientid ); ADDDWORD ( pak, 0 ); ADDDWORD ( pak, 16 ); GServer->SendToVisible( &pak, thisclient ); break; } } BEGINPACKET( pak, 0x7f8 ); ADDSTRING ( pak, "HUD_DawnSea_Destroyed_Gate1" ); ADDBYTE ( pak, 0x00 ); thisgroup->SendToMembers(&pak); } if(fragments == 0) { for(UINT i=0;i<NPCList.size();i++) { CNPC* thisnpc = NPCList.at(i); if(thisnpc->npctype == 3704 && thisnpc->pos.x == 5167 && thisnpc->pos.x == 4920 && thisnpc->team == thisgroup->GroupId) DeleteNPC(thisnpc); break; } BEGINPACKET( pak, 0x7f8 ); ADDSTRING ( pak, "HUD_DawnSea_Destroyed_Gate2" ); ADDBYTE ( pak, 0x00 ); thisgroup->SendToMembers(&pak); } }
bool MetaData(const char* filepath, cFields& fields, cRow& props) { #define ADD(x, t) do { if (t) { fields.push_back(x); props.push_back(t); } } while(0) #define ADDSTRING(x, t) do { if (!t.empty()) { fields.push_back(x); props.push_back(t); } } while(0) #define ADDINT(x, t) do { std::string c = *itoa(t); if (!c.empty()){ fields.push_back(x); props.push_back(c);} } while(0) TagLib::FileRef f(filepath); fields.clear(); props.clear(); //cTag t; //const char* tmp = NULL; std::string tmp; if (f.isNull()) { std::cerr<< "Taglib failed on " << filepath << std::endl; ADD("metadata_needs_update", "2"); // failure return false; } TagLib::Tag *tag = f.tag(); if (tag) { #if 0 tmp = toString(tag->title()).c_str(); ADD("title", tmp); tmp = toString(tag->artist()).c_str(); ADD("artist", tmp); tmp = toString(tag->album()).c_str(); ADD("album", tmp); tmp = toString(tag->comment()).c_str(); ADD("comment", tmp); tmp = toString(tag->genre()).c_str(); ADD("genre", tmp); #else tmp = toString(tag->title()); ADDSTRING("title", tmp); tmp = toString(tag->artist()); ADDSTRING("artist", tmp); tmp = toString(tag->album()); ADDSTRING("album", tmp); tmp = toString(tag->comment()); ADDSTRING("comment", tmp); tmp = toString(tag->genre()); ADDSTRING("genre", tmp); #endif //ADDINT("track", tag->track()); ADDINT("year", tag->year()); } TagLib::AudioProperties *prop = f.audioProperties(); if (prop) { ADDINT("bitrate", prop->bitrate()); ADDINT("samplerate", prop->sampleRate()); // ADDINT("channels", prop->channels()); ADDINT("length" , prop->length()); } ADD("metadata_needs_update", "0"); return true; }
// NPC Whisper to a character bool CWorldServer::NPCWhisper( CPlayer* thisclient, CMonster* thismon, char msg[200], char npc[50] ) { BEGINPACKET( pak, 0x0784 ); ADDSTRING( pak, npc ); ADDBYTE( pak, 0 ); ADDSTRING( pak, msg ); ADDBYTE( pak, 0 ); thisclient->client->SendPacket(&pak); return true; }
// from Paul_T bool CWorldServer::SendGlobalMSG( CPlayer* thisclient, char msg[200] ) { BEGINPACKET( pak, 0x0784 ); ADDSTRING( pak, thisclient->CharInfo->charname ); ADDBYTE( pak, 0 ); ADDSTRING( pak, msg ); ADDBYTE( pak, 0 ); SendToAll(&pak); return true; }
bool CWorldServer::NPCShout2( CMonster* thismon, char* msg, char* npc ) { BEGINPACKET(pak, 0x0785); ADDSTRING ( pak, npc ); ADDBYTE ( pak, 0 ); ADDSTRING ( pak, msg ); ADDBYTE ( pak, 0 ); SendToMap ( &pak, thismon->Position->Map ); return true; }
// Send a PM from a specific NPC using the blue text of the shout system. Used in custom quests bool CWorldServer::NPCMessage( CPlayer* thisclient, char msg[200], char npc[50]) { if (npc == "") strcpy(npc, "Event NPC"); BEGINPACKET(pak, 0x0785); ADDSTRING ( pak, npc ); ADDBYTE ( pak, 0 ); ADDSTRING ( pak, msg ); ADDBYTE ( pak, 0 ); thisclient->client->SendPacket(&pak); return true; }
struct Symbol* relational_expression(struct RelationalExpression* node) { if (node->type == 0) return shift_expression(node->shiftExpression); struct Symbol* symbol1 = load_symbol(relational_expression(node->relationalExpression)); struct Symbol* symbol2 = load_symbol(shift_expression(node->shiftExpression)); test_relation(&symbol1, &symbol2); struct Symbol* symbol3; if (node->type == 1) symbol3 = test_calculable2(&symbol1, &symbol2, '<'); else symbol3 = test_calculable2(&symbol1, &symbol2, '>'); if (symbol3) return symbol3; symbol3 = new_symbol("", 0, 2, 1, 0, 0, 0); char c = 's'; if ((symbol1->specifier & (1 << 9)) > 0 || symbol1->stars) c = 'u'; ADDSTRING(" "); code_gen_symbol('%', symbol3); if (symbol2->stars == 0 && (symbol2->specifier & (3 << 6)) != 0) { ADDSTRING(" = fcmp "); if (node->type == 1 || node->type == 3) { ADDSTRING("olt "); } else { ADDSTRING("ogt "); } } else { ADDSTRING(" = icmp "); *g_ptr++ = c; if (node->type == 1 || node->type == 3) { ADDSTRING("lt "); } else { ADDSTRING("gt "); } } code_gen_type_specifier(symbol1->specifier,0, symbol1->length, symbol1->stars); ADDSTRING(" "); code_gen_symbol('%', symbol1); ADDSTRING(", "); code_gen_symbol('%', symbol2); ADDSTRING("\n"); return symbol3; }
// Clan chat bool CCharServer::pakClanChat ( CCharClient* thisclient, CPacket* P ) { if(!thisclient->isLoggedIn) return false; char* tmp; if (P->Buffer[0]=='/') { char* command = strtok( (char*)&(*P).Buffer[1] , " "); if(command==NULL) return true; if(strcmp(command, "pak")==0)//read cpacket.txt and send it (for test packets) { int comando = 0; if ((tmp = strtok(NULL, " "))==NULL) return true; comando=atoi(tmp); char buffer; FILE *packet1 = fopen("cpacket.txt","r"); BEGINPACKET(pak,comando); if(packet1==NULL) { printf("Error opening packet1.txt for 716!\n"); return true; } while((fscanf(packet1,"%c",&buffer))!=EOF) ADDBYTE(pak,buffer); fclose(packet1); thisclient->SendPacket( &pak ); return true; } } char* text = new (nothrow) char[P->Size]; if(text==NULL) { Log(MSG_ERROR, "Error allocing memory" ); return false; } memcpy( text, &P->Buffer, P->Size ); CClans* thisclan = (CClans*) GetClanByID ( thisclient->clanid ); if(thisclan!=NULL) { BEGINPACKET( pak, 0x787 ); ADDSTRING ( pak, thisclient->charname ); ADDBYTE ( pak, 0x00 ); ADDSTRING ( pak, text ); ADDBYTE ( pak, 0x00 ); SendToClanMembers(thisclan->id,&pak); } delete []text; return true; }
// from Paul_T bool CWorldServer::SendGlobalMSG( CPlayer* thisclient, char* Format, ... ) { char buf[512]; va_list ap; va_start( ap, Format ); vsprintf( buf, Format, ap ); BEGINPACKET( pak, 0x0784 ); ADDSTRING( pak, thisclient->CharInfo->charname ); ADDBYTE( pak, 0 ); ADDSTRING( pak, buf ); ADDBYTE( pak, 0 ); SendToAll(&pak); va_end( ap ); return true; }
// from Paul_T bool CWorldServer::SendPM( CPlayer* thisclient, char* Format, ... ) { char buf[512]; va_list ap; va_start( ap, Format ); vsprintf( buf, Format, ap ); BEGINPACKET( pak, 0x0784 ); ADDSTRING( pak, "Server" ); ADDBYTE( pak, 0 ); ADDSTRING( pak, buf ); ADDBYTE( pak, 0 ); thisclient->client->SendPacket(&pak); va_end( ap ); return true; }
// Send server list bool CLoginServer::pakGetServers( CLoginClient* thisclient, CPacket* P ) { if( !thisclient->isLoggedIn ) return false; MYSQL_ROW row; DWORD servernum = GETDWORD( (*P), 0 ); MYSQL_RES *result = DB->QStore( "SELECT id,name,connected,maxconnections FROM channels WHERE owner=%i and type=2", servernum ); if(result==NULL) return false; BEGINPACKET( pak, 0x704 ); ADDDWORD ( pak, servernum ); ADDBYTE ( pak, (BYTE)mysql_num_rows( result ) ); while(row = mysql_fetch_row(result)) { unsigned int status = (atoi(row[2]) * 100) / atoi(row[3]); ADDWORD( pak, atoi( row[0])); ADDBYTE( pak, 0 ); ADDWORD( pak, status ); ADDSTRING( pak, row[1]); ADDBYTE( pak, 0 ); } DB->QFree( ); thisclient->SendPacket ( &pak ); return true; }
// NPC Shout to the current map bool CWorldServer::NPCShout( CMonster* thismon, char* msg, char* npc,int mapid) { BEGINPACKET(pak, 0x0785); ADDSTRING ( pak, npc ); ADDBYTE ( pak, 0 ); ADDSTRING ( pak, msg ); ADDBYTE ( pak, 0 ); if(mapid!=0) SendToMap ( &pak, mapid ); else SendToMap ( &pak, thismon->Position->Map ); return true; }
// Send server list bool CLoginServer::pakGetServers( CLoginClient* thisclient, CPacket* P ) { if( !thisclient->isLoggedIn ) return false; MYSQL_ROW row; DWORD servernum = GETDWORD( (*P), 0 ); MYSQL_RES *result = DB->QStore( "SELECT id,name,connected,maxconnections FROM channels WHERE owner=%i and type=2", servernum ); if(result==NULL) return false; BEGINPACKET( pak, 0x704 ); ADDDWORD ( pak, servernum ); ADDBYTE ( pak, (BYTE)mysql_num_rows( result ) ); while(row = mysql_fetch_row(result)) { UINT connected = atoi(row[2]); UINT maxconnections = atoi(row[3]); BYTE id = atoi( row[0] ); string name = row[1]; //BYTE status = (((100 * connected) / maxconnections==0?1:maxconnections) / 5) & 0xff; unsigned int status = (connected * 100) / maxconnections; ADDWORD( pak, id ); ADDBYTE( pak, 0 ); ADDWORD( pak, status ); ADDSTRING( pak, name.c_str() ); ADDBYTE( pak, 0 ); } DB->QFree( ); thisclient->SendPacket ( &pak ); return true; }
// Send server IP bool CLoginServer::pakGetIP( CLoginClient* thisclient, CPacket* P ) { if (!thisclient->isLoggedIn) return false; ; MYSQL_ROW row; DWORD servernum = GETDWORD( (*P), 0 ); BYTE channelnum = GETBYTE( (*P), 4 ); BEGINPACKET( pak, 0x70a ); if(!DB->QExecute( "UPDATE accounts SET lastsvr=%i,lastip='%s',lasttime=UNIX_TIMESTAMP( NOW() ) WHERE id=%i", channelnum, inet_ntoa( thisclient->clientinfo.sin_addr ), thisclient->userid)) return false; MYSQL_RES *result = DB->QStore( "SELECT host,port,lanip,lansubmask,connected,maxconnections FROM channels WHERE id=%i and type=1", servernum ); if(result==NULL) return false; if(mysql_num_rows(result)!=1) { Log(MSG_WARNING, "Player selected a invalid channel or channel offline" ); DB->QFree( ); return true; } row = mysql_fetch_row(result); UINT connected = atoi(row[4]); UINT maxconnections = atoi(row[5]); ADDBYTE( pak, 0 ); ADDDWORD( pak, thisclient->userid ); ADDDWORD( pak, 0x87654321 ); if(strcmp(thisclient->ClientSubNet,row[3])==0)//from lan { ADDSTRING( pak, row[2] ); Log(MSG_INFO, "Lan: %s choice channel #%i", thisclient->username.c_str(), channelnum); } else if(strcmp( thisclient->ClientSubNet ,"127.0.0")==0)//same computer { ADDSTRING( pak, "127.0.0.1" ); Log(MSG_INFO, "Server: %s choice channel #%i", thisclient->username.c_str(), channelnum); } else { ADDSTRING( pak, row[0] ); Log(MSG_INFO, "Inet: %s choice channel #%i", thisclient->username.c_str(), channelnum); } ADDBYTE( pak, 0 ); ADDWORD( pak, atoi(row[1]) ); DB->QFree( ); thisclient->SendPacket ( &pak ); return true; }
// Send Clan information bool CCharServer::SendClanInfo (CCharClient* thisclient) { if( thisclient->clanid > 0 ) { CClans *thisclan = GetClanByID(thisclient->clanid); if(thisclan!=NULL) { BEGINPACKET( pak, 0x7e0); ADDBYTE ( pak, 0x33);//0x33 you have invited to clan ADDWORD ( pak, thisclan->id);// clan id ADDBYTE ( pak, 0x00);// ADDBYTE ( pak, 0x00); ADDWORD ( pak, thisclan->back);//Clan Background ADDWORD ( pak, thisclan->logo);//Clan logo ADDBYTE ( pak, thisclan->grade);//Clan grade ADDBYTE ( pak, thisclient->clan_rank);// Clan rank (0 = red rokie / 6 = master) ADDDWORD ( pak, thisclan->cp);//Clan Points ADDDWORD ( pak, 0x00000064); ADDDWORD ( pak, 0x00000000); //Clan found ADDDWORD ( pak, 0x00000000); ADDBYTE ( pak, 0x01); for(int i=34;i<156;i++) ADDBYTE ( pak, 0x00); ADDWORD ( pak, 0x0000); ADDBYTE ( pak, 0x00); ADDSTRING ( pak, thisclan->name);//Clan Name ADDBYTE ( pak, 0x00); ADDSTRING ( pak, thisclan->slogan);//Clan slogan ADDBYTE ( pak, 0x00); ADDSTRING ( pak, thisclan->news);//Clan news ADDBYTE ( pak, 0x00); thisclient->SendPacket(&pak); //Put the player online in clan for(UINT i=0;i<thisclan->ClanMembers.size();i++) { CClanMembers* ClanMember = thisclan->ClanMembers.at( i );; CCharClient* otherclient = GetClientByID( ClanMember->id ); if(otherclient!=NULL) ChangeClanStatus (thisclient, otherclient, thisclient->channel);//send channel here } } } return true; }
bool CWorldServer::SendSysMsg( CPlayer* thisclient, string message ) { BEGINPACKET( pak, 0x7df ); ADDBYTE ( pak, 0xf1 ); ADDSTRING ( pak, message.c_str( )); ADDBYTE ( pak, 0x00 ); thisclient->client->SendPacket( &pak ); return true; }
// Party Chat bool CWorldServer::pakPartyChat( CPlayer* thisclient, CPacket* P ) { CParty* party = thisclient->Party->party; if(party==NULL) return true; BEGINPACKET( pak, 0x786 ); ADDWORD ( pak, thisclient->clientid ); ADDSTRING ( pak, P->Buffer ); ADDBYTE ( pak, 0 ); party->SendToMembers( &pak ); return true; }
// delete/resurect character bool CCharServer::pakDeleteChar( CCharClient* thisclient, CPacket* P ) { if(!thisclient->isLoggedIn) return false; char* name = (char*)&P->Buffer[2]; MYSQL_RES *result; MYSQL_ROW row; result = DB->QStore("SELECT account_name FROM characters WHERE char_name='%s' LIMIT 1", name); if(result==NULL) return false; row = mysql_fetch_row(result); if (strcmp(row[0], thisclient->username)!=0) { Log(MSG_HACK, "User %s tried deleting another users (%s) character.", thisclient->username, name); DB->QFree( ); return false; } DB->QFree( ); short int action = GETBYTE((*P), 1 ); unsigned long int DeleteTime = 0; switch(action) { case 0x00://Resurect { DeleteTime = 0; if(!DB->QExecute(" UPDATE characters SET deletetime=0 WHERE char_name='%s'", (char*)&P->Buffer[2] )) return false; } break; case 0x01://Delete { DeleteTime = GetServerTime( ) + Config.DeleteTime; if(!DB->QExecute(" UPDATE characters SET deletetime=%i WHERE char_name='%s'", DeleteTime, (char*)&P->Buffer[2] )) return false; } break; } BEGINPACKET( pak, 0x714 ); if(DeleteTime > 0 ) { ADDDWORD ( pak, Config.DeleteTime ); } else { ADDDWORD ( pak, 0x00000000 ); } ADDSTRING ( pak, (char*)&P->Buffer[2] ); ADDBYTE ( pak, 0x00 ); thisclient->SendPacket( &pak ); return true; }
//LMA: disconnect a client from chatroom. bool CCharServer::DisconnectClientFromChat( CCharClient* thisclientwc ) { //LMA: resetting chatroom ID. if(thisclientwc->chatroom_id!=0) { if(chatroom_list.find(thisclientwc->chatroom_id)!=chatroom_list.end()) { for (int k=0; k<chatroom_list[thisclientwc->chatroom_id]->People_list.size(); k++) { if(chatroom_list[thisclientwc->chatroom_id]->People_list.at(k)->charid==thisclientwc->charid) { //Deleting the guy from the chatroom list. chatroom_list[thisclientwc->chatroom_id]->People_list.erase(chatroom_list[thisclientwc->chatroom_id]->People_list.begin()+k); break; } } if (chatroom_list[thisclientwc->chatroom_id]->People_list.size()==0) { chatroom_list.erase(thisclientwc->chatroom_id); } else { //TODO: send a packet to other people to tell them this guy has deconnected from chatroom. for (int k=0; k<chatroom_list[thisclientwc->chatroom_id]->People_list.size(); k++) { CCharClient* otherclient=GetClientByID(chatroom_list[thisclientwc->chatroom_id]->People_list.at(k)->charid); if(otherclient==NULL) { continue; } BEGINPACKET( pak, 0x7e3 ); ADDBYTE ( pak, 0x16 ); ADDWORD ( pak, thisclientwc->userid ); ADDDWORD ( pak, thisclientwc->charid ); ADDSTRING ( pak, thisclientwc->charname ); ADDBYTE ( pak, 0x00 ); otherclient->SendPacket( &pak ); } } } thisclientwc->chatroom_id=0; } return true; }
// NPC Announce to the server bool CWorldServer::NPCAnnounce( char* msg, char* npc, int mapid) { //LMA: We only announce in the NPC's map //Log(MSG_INFO,"%s announces: %s",npc,msg); BEGINPACKET( pak, 0x702 ); ADDSTRING( pak, npc ); ADDSTRING( pak, "> " ); ADDSTRING( pak, msg); ADDBYTE( pak, 0x00); if(mapid!=0) { SendToMap ( &pak, mapid ); } else { SendToAll( &pak ); } return true; }
// Change player status in clan ((channel) = online/ 0xff = offline) bool CCharServer::ChangeClanStatus (CCharClient* thisclient, CCharClient* otherclient, int channel) { if (thisclient->charid !=otherclient->charid) { BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x73 );//Change player status ADDBYTE ( pak, 0x00 ); ADDBYTE ( pak, channel );//CANAL ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, thisclient->level ); ADDWORD ( pak, thisclient->job ); ADDSTRING ( pak, thisclient->charname ); ADDBYTE ( pak, 0x00 ); otherclient->SendPacket(&pak); } return true; }
// Send clan members bool CCharServer::pakClanMembers ( CCharClient* thisclient ) { CClans* thisclan = (CClans*) GetClanByID( thisclient->clanid ); if(thisclan!=NULL) { BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x72 );//Send clan members for(UINT i=0;i<thisclan->ClanMembers.size( );i++) { CClanMembers* thismember = thisclan->ClanMembers.at( i ); if(thismember==NULL) continue; CCharClient* otherclient = (CCharClient*) GetClientByID (thismember->id); if(otherclient!=NULL) { ADDBYTE ( pak, thismember->clan_rank ); //clan rank ADDBYTE ( pak, otherclient->channel ); //channel (0x01 = channel 1) ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, otherclient->level );// Level ADDWORD ( pak, otherclient->job );// Job } else { ADDBYTE ( pak, thismember->clan_rank); //clan rank ADDBYTE ( pak, 0xff ); //channel (0xff = offline) ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, 0x0000 );// Level ADDWORD ( pak, 0x0000 );// Job } ADDSTRING ( pak, thismember->name ); ADDBYTE ( pak, 0x00 ); } thisclient->SendPacketCpy( &pak ); } return true; }
bool CPlayer::SpawnToPlayer( CPlayer* player, CPlayer* otherclient ) { BEGINPACKET ( pak, 0x793 ); ADDWORD ( pak, clientid); // Client ID ADDFLOAT ( pak, Position->current.x*100 ); // Position X ADDFLOAT ( pak, Position->current.y*100 ); // Position Y ADDFLOAT ( pak, Position->destiny.x*100 ); // Position X ADDFLOAT ( pak, Position->destiny.y*100 ); // Position Y // Observe: 430 Extra Bytes ADDDWORD ( pak, 0 ); // ?? ADDWORD ( pak, 0 ); // ?? // End switch (Status->Stance) { case WALKING: ADDBYTE ( pak, 0x00 ); // Walking break; case RUNNING: ADDBYTE ( pak, 0x01 ); // Running break; case DRIVING: case MOUNTED: ADDBYTE ( pak, 0x02 ); // Driving // Observe: Mounts aswell break; default: ADDBYTE ( pak, 0x00 ); // Default: Running } if(Status->Stance == 0x01) { ADDWORD ( pak, 0x000a ); ADDWORD ( pak, 0x0000 ); } else if(IsDead()) { ADDWORD ( pak, 0x0003 ); ADDWORD ( pak, 0x0000 ); } else if(Position->destiny.x != Position->current.y || Position->destiny.y != Position->current.y) { ADDWORD ( pak, 0x0001 ); ADDWORD ( pak, Battle->atktarget ); } else if(Battle->atktarget != 0) { ADDWORD ( pak, 0x0002 ); ADDWORD ( pak, Battle->atktarget ); } else { ADDDWORD( pak, 0x00000000 ); } pvp_id = otherclient->ReturnPvp(player,otherclient); ADDDWORD (pak, pvp_id); ADDDWORD ( pak, GServer->BuildBuffs( this ) ); // Buffs ADDBYTE ( pak, CharInfo->Sex ); // Gender ADDDWORD ( pak, Stats->Move_Speed ); // Movement Speed ADDBYTE ( pak, CharInfo->HairColor ); // HairColor ADDDWORD ( pak, CharInfo->Face ); // Face Type ADDDWORD ( pak, CharInfo->Hair ); // Hair Type if(items[142].itemnum != 0) // Cap { ADDWORD ( pak, items[142].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[142])); } else { ADDWORD ( pak, items[2].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[2])); } if(items[143].itemnum != 0) // Body { ADDWORD ( pak, items[143].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[143])); } else { ADDWORD ( pak, items[3].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[3])); } if(items[144].itemnum != 0) // Gloves { ADDWORD ( pak, items[144].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[144])); } else { ADDWORD ( pak, items[5].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[5])); } if(items[145].itemnum != 0) // Shoes { ADDWORD ( pak, items[145].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[145])); } else { ADDWORD ( pak, items[6].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[6])); } if(items[146].itemnum != 0) // Mask { ADDWORD ( pak, items[146].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[146])); } else { ADDWORD ( pak, items[1].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[1])); } if(items[147].itemnum != 0) // Back { ADDWORD ( pak, items[147].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[147])); } else { ADDWORD ( pak, items[4].itemnum ); ADDWORD ( pak, GServer->BuildItemRefine( items[4])); } ADDWORD ( pak, items[7].itemnum ); // Weapon ADDWORD ( pak, GServer->BuildItemRefine( items[7] ) ); ADDWORD ( pak, items[8].itemnum ); // Sub-Weapon ADDWORD ( pak, GServer->BuildItemRefine( items[8] ) ); ADDWORD ( pak, (items[132].itemnum << 5)); // Arrows ADDWORD ( pak, (items[133].itemnum << 5)); // Bullets ADDWORD ( pak, (items[134].itemnum << 5)); // Cannons ADDWORD ( pak, CharInfo->Job ); // Class ADDBYTE ( pak, Stats->Level ); // Level ADDWORD ( pak, items[135].itemnum); // Frame ADDWORD ( pak, GServer->BuildItemRefine(items[135])); ADDWORD ( pak, items[136].itemnum ); // Engine ADDWORD ( pak, GServer->BuildItemRefine(items[136])); ADDWORD ( pak, items[137].itemnum ); // Wheels ADDWORD ( pak, GServer->BuildItemRefine(items[137])); ADDWORD ( pak, items[138].itemnum ); // Weapon ADDWORD ( pak, GServer->BuildItemRefine(items[138])); ADDWORD ( pak, items[139].itemnum ); // Ability ADDWORD ( pak, GServer->BuildItemRefine(items[139])); // Observe: 434 Extra Bytes if(Status->Stance != MOUNTED) { ADDDWORD ( pak, 0 ); // ?? ADDWORD ( pak, 0 ); // ?? } else { ADDBYTE ( pak, 1 ); ADDDWORD ( pak, CharInfo->Mount ); ADDBYTE ( pak, 0 ); } // End 434 ADDWORD ( pak, (Stats->HP <= 0)?0x00:0xea7b ); // HP if(Shop->open) { ADDWORD ( pak, 0x0002 ); // Shop } else if(otherclient->isInvisibleMode && !player->isInvisibleMode) { ADDWORD ( pak, 0x0001 ); // Invisible } else { ADDWORD ( pak, 0x0000 ); // Visible } ADDBYTE ( pak, 0x00 ); // Fairy? ADDBYTE ( pak, 0 ); ADDBYTE ( pak, CharInfo->HairColor ); // Another HairColor?? ADDSTRING ( pak, CharInfo->charname ); // Character Name ADDBYTE ( pak, 0x00 ); if(Shop->open) { ADDWORD ( pak, Shop->ShopType); // Shop Type ADDSTRING( pak, Shop->name); // Shopname ADDBYTE ( pak, 0x00); } if (!IsDead()) { if (Status->HP_up != 0xff) { ADDWORD ( pak, MagicStatus[Status->HP_up].Value ); } if (Status->Dash_up != 0xff) { ADDWORD ( pak, MagicStatus[Status->Dash_up].Value ); } if (Status->Haste_up != 0xff) { ADDWORD ( pak, MagicStatus[Status->Haste_up].Value ); } } if(Clan->clanid != 0) { ADDDWORD( pak, Clan->clanid ); ADDWORD ( pak, Clan->back ); ADDWORD ( pak, Clan->logo ); ADDBYTE ( pak, Clan->grade ); ADDBYTE ( pak, Clan->clanrank ); ADDSTRING( pak, Clan->clanname ); ADDBYTE ( pak, 0x00 ) }
// Party Manager bool CWorldServer::pakPartyManager( CPlayer* thisclient, CPacket* P ) { unsigned int action = GETBYTE((*P),0); switch(action) { case 0x02://Acepto { if(thisclient->Party->party!=NULL)// have party return true; unsigned int clientid = GETWORD((*P),1); if (clientid == thisclient->clientid) { Log(MSG_WARNING, "User %s tried to party with himself\n", thisclient->CharInfo->charname); return false; //kick the cheater } CPlayer* otherclient = GetClientByID( clientid, thisclient->Position->Map ); if(otherclient==NULL) { BEGINPACKET( pak, 0x7d1 ); ADDBYTE ( pak, 0x00 );//No encontro el ID ADDWORD ( pak, clientid ); ADDBYTE ( pak, 0x00 ); thisclient->client->SendPacket( &pak ); return true; } CParty* party = otherclient->Party->party; if(party!=NULL) { //LMA: Refreshing Capacity if needed party->RefreshMax(); if(party->Members.size()>=party->Capacity) { SendSysMsg( thisclient, "Party is Full" ); return true; } } if(abs(otherclient->Stats->Level-thisclient->Stats->Level)>(Config.Partygap+1)) { BEGINPACKET( pak, 0x7d1 ); ADDBYTE ( pak, 0x07 );//Level inapropiado ADDWORD ( pak, clientid ); ADDBYTE ( pak, 0x00 ); thisclient->client->SendPacket( &pak ); return true; } BEGINPACKET( pak, 0x7d1 ); ADDBYTE ( pak, 0x02 );//Acepto Party ADDWORD ( pak, otherclient->clientid ); ADDBYTE ( pak, 0x00 ); otherclient->client->SendPacket( &pak ); if( party==NULL ) { // new party CParty* thisparty = new CParty; thisparty->AddPlayer( otherclient ); AddParty( thisparty ); otherclient->Party->IsMaster = true; party = thisparty; } //Send Party Level and Party Exp RESETPACKET( pak, 0x7d4 ); // ADDBYTE ( pak, party->PartyLevel ); ADDDWORD ( pak, party->Exp ); thisclient->client->SendPacket( &pak ); thisclient->Party->IsMaster = false; // Send New Party Member info to other players RESETPACKET( pak, 0x7d2 ); ADDBYTE ( pak, party->Option ); ADDBYTE ( pak, 0x01 ); ADDDWORD ( pak, thisclient->CharInfo->charid ); ADDWORD ( pak, thisclient->clientid ); ADDWORD ( pak, thisclient->Stats->MaxHP ); ADDWORD ( pak, thisclient->Stats->HP ); //ADDDWORD ( pak, 0x00000000 );//Tomiz: Was not commented before ADDDWORD ( pak, BuildBuffs( thisclient ));//Tomiz: Buff Data //ADDDWORD ( pak, 0x0000000f );//Tomiz: Was not commented before ADDDWORD ( pak, 0x1f40008c );//Tomiz ADDWORD ( pak, 0x1388 ); ADDSTRING ( pak, thisclient->CharInfo->charname ); ADDBYTE ( pak, 0x00 ); party->SendToMembers( &pak ); // Send To New Party Member the members List RESETPACKET( pak, 0x7d2 ); ADDBYTE ( pak, party->Option ); ADDBYTE ( pak, party->Members.size() ); for(int i=0;i<party->Members.size();i++) { CPlayer* member= party->Members.at(i); ADDDWORD ( pak, member->CharInfo->charid ); ADDWORD ( pak, member->clientid ); ADDWORD ( pak, member->Stats->MaxHP ); ADDWORD ( pak, member->Stats->HP ); //ADDDWORD ( pak, 0x00000000 );//Tomiz: Was not commented before ADDDWORD ( pak, BuildBuffs( member ));//Tomiz: Buff Data //ADDDWORD ( pak, 0x0000000f );//Tomiz: Was not commented before ADDDWORD ( pak, 0x7200005b );//Tomiz ADDWORD ( pak, 0x1388 ); ADDSTRING ( pak, member->CharInfo->charname ); ADDBYTE ( pak, 0x00 ); } thisclient->client->SendPacket( &pak ); party->AddPlayer( thisclient ); } break; case 0x04://No acepto { unsigned int clientid = GETWORD((*P),1); CPlayer* otherclient = GetClientByID( clientid, thisclient->Position->Map ); if(otherclient==NULL) { BEGINPACKET( pak, 0x7d1 ); ADDBYTE ( pak, 0x00 );//No encontro el ID ADDWORD ( pak, clientid ); ADDBYTE ( pak, 0x00 ); thisclient->client->SendPacket( &pak ); return true; } BEGINPACKET( pak, 0x7d1 ); ADDBYTE ( pak, 0x04 );//No acepto ADDWORD ( pak, thisclient->clientid ); ADDBYTE ( pak, 0x00 ); otherclient->client->SendPacket( &pak ); } break; default: Log(MSG_WARNING,"Party Manager unknown action: %i", action); } return true; }
// Messenger actions (add/remove/invite) bool CCharServer::pakMessengerManager ( CCharClient* thisclient, CPacket* P ) { BYTE action = GETBYTE((*P),0); switch (action) { case 0x01://wanna be my friend? { char* nick = new (nothrow) char[P->Size-7]; if(nick==NULL) { Log(MSG_ERROR, "Error allocing memory: pakMessengerManager 1" ); return false; } memcpy( nick, &P->Buffer[1], P->Size-7 ); Log(MSG_INFO,"%s Trying to invite %s",nick,thisclient->charname); CCharClient* otherclient = (CCharClient*) GetClientByName (nick); if(otherclient!=NULL) {//Send friend invitation (check this one) BEGINPACKET( pak, 0x7e1 ); ADDBYTE ( pak, 0x01 ); ADDWORD ( pak, 0x0000 ); ADDSTRING ( pak, thisclient->charname ); ADDBYTE ( pak, 0x00 ); otherclient->SendPacket(&pak); Log(MSG_INFO,"%s exists, invite sent to %s",nick,otherclient->charname); } else {//This charname doesnt exist BEGINPACKET( pak, 0x7e1 ); ADDBYTE ( pak, 0x04 ); ADDSTRING ( pak, nick ); ADDBYTE ( pak, 0x00 ); thisclient->SendPacket(&pak); Log(MSG_INFO,"invite: %s doesn't exist",nick); } delete []nick; } break; case 0x02://yes i want { char* nick = new (nothrow) char[P->Size-9]; if(nick==NULL) { Log(MSG_ERROR, "Error allocing memory: pakMessengerManager 2" ); return false; } memcpy( nick, &P->Buffer[3], P->Size-9 ); CCharClient* otherclient = (CCharClient*) GetClientByName (nick); if(otherclient!=NULL) { BEGINPACKET( pak, 0x7e1 ); ADDBYTE ( pak, 0x02 ); ADDWORD ( pak, thisclient->charid ); ADDBYTE ( pak, 0x00 ); ADDWORD ( pak, 0x0000 ); ADDSTRING ( pak, thisclient->charname ); ADDBYTE ( pak, 0x00); otherclient->SendPacket(&pak); //Add friend to my friend list(sql) if(!DB->QExecute("INSERT INTO list_friend (id,idfriend,namefriend) VALUES (%i,%i,'%s')",otherclient->charid,thisclient->charid,thisclient->charname)) { Log(MSG_WARNING,"error addind %s to %s friend list",otherclient->charname,thisclient->charname); return false; } CFriendList * newfriend1 = new (nothrow) CFriendList; if(newfriend1==NULL) return false; newfriend1->id = otherclient->charid; //friendid strcpy(newfriend1->name, otherclient->charname); //friend name thisclient->FriendList.push_back( newfriend1 ); RESETPACKET( pak, 0x7e1 ); ADDBYTE ( pak, 0x02 ); ADDWORD ( pak, otherclient->charid ); ADDBYTE ( pak, 0x00 ); ADDWORD ( pak, 0x0000 ); ADDSTRING ( pak, otherclient->charname ); ADDBYTE ( pak, 0x00); thisclient->SendPacket(&pak); //Add me to his friend list (sql) if(!DB->QExecute("INSERT INTO list_friend (id,idfriend,namefriend) VALUES (%i,%i,'%s')", thisclient->charid,otherclient->charid,otherclient->charname)) return false; CFriendList * newfriend2 = new (nothrow) CFriendList; if(newfriend2==NULL) return false; newfriend2->id = thisclient->charid; //friendid strcpy(newfriend2->name, thisclient->charname); //friend name otherclient->FriendList.push_back( newfriend2 ); Log(MSG_INFO,"accept %s ok",nick); } else//not founded { BEGINPACKET( pak, 0x7e1 ); ADDBYTE ( pak, 0x04 ); ADDSTRING ( pak, nick ); ADDBYTE ( pak, 0x00 ); thisclient->SendPacket(&pak); Log(MSG_INFO,"accept: %s doesn't exist",nick); } delete []nick; } break; case 0x03://no, i dont want { char* nick = new (nothrow) char[P->Size-9]; if(nick==NULL) { Log(MSG_ERROR, "Error allocing memory: pakMessengerManager 3" ); return false; } memcpy( nick, &P->Buffer[3], P->Size-9 ); CCharClient* otherclient = (CCharClient*) GetClientByName (nick); if(otherclient!=NULL) { BEGINPACKET( pak, 0x7e1 ); ADDBYTE ( pak, 0x03 ); ADDSTRING ( pak, thisclient->charname ); ADDBYTE ( pak, 0x00); otherclient->SendPacket(&pak); Log(MSG_INFO,"refuse: %s ok",nick); } else { BEGINPACKET( pak, 0x7e1 ); ADDBYTE ( pak, 0x04 ); ADDWORD ( pak, 0x0000 ); ADDSTRING ( pak, nick ); ADDBYTE ( pak, 0x00 ); thisclient->SendPacket(&pak); Log(MSG_INFO,"refuse: %s doesn't exist",nick); } } break; case 0x05://delete user. { WORD id = GETWORD ((*P),1); if(!DB->QExecute("DELETE FROM list_friend WHERE id=%i and idfriend=%i",thisclient->charid,id)) { Log(MSG_INFO,"user failed to delete friend slot %i",thisclient->charname,id); return false; } Log(MSG_INFO,"user %s deletes friend slot %i",thisclient->charname,id); CCharClient* otherclient = (CCharClient*) GetClientByID(id); if(otherclient!=NULL) { ChangeMessengerStatus ( thisclient, otherclient, 0x08); } } break; case 0xfa://messenger logout { WORD id = GETWORD ((*P),1); CCharClient* ctherclient = (CCharClient*) GetClientByID(id); if(ctherclient==NULL) return true; ctherclient->logout = true; for(UINT i=0;i<ctherclient->FriendList.size();i++) { CFriendList* thisfriend = ctherclient->FriendList.at( i ); CCharClient* otherclient = (CCharClient*) GetClientByID( thisfriend->id ); if(otherclient!=NULL) { ChangeMessengerStatus ( ctherclient, otherclient, 0x08); } } //Logout in clan ClanLogout ( ctherclient ); } break; default: Log( MSG_INFO, "Friend action unknown: %i", action ); break; } return true; }
// Create a new clan bool CWorldServer::pakCreateClan ( CPlayer* thisclient, CPacket* P ) { if(thisclient->CharInfo->Zulies<1000000) return true; thisclient->CharInfo->Zulies -= 1000000; MYSQL_ROW row; int background = GETWORD((*P),1); int icon = GETWORD((*P),3); char *name = ""; char *slogan = ""; name=(char*)&P->Buffer[5]; slogan=(char*)&P->Buffer[strlen(name)+6]; //Check if name already exists MYSQL_RES *result = DB->QStore("SELECT name FROM list_clan WHERE name='%s'", name); if(result==NULL) return true; if ( mysql_num_rows( result ) > 0 ) { BEGINPACKET( pak, 0x07e0 ); ADDWORD ( pak, 0x42 ); thisclient->client->SendPacket( &pak ); DB->QFree( ); return true; } DB->QFree( ); //Check if user can create a clan if( thisclient->Clan->clanid != 0 ) { BEGINPACKET( pak, 0x07e0 ); ADDWORD ( pak, 0x44 ); thisclient->client->SendPacket( &pak ); return true; } //Add clan to sql table //LMA: inserting slogan now char * lma_slogan = new char[strlen(slogan) + 1]; //char lma_slogan[200]=""; strcpy(lma_slogan,slogan); char * new_slogan = new char[strlen(lma_slogan)*3 +1]; mysql_real_escape_string(DB->Mysql, new_slogan,lma_slogan,strlen(lma_slogan)); //mysql_real_escape_string(DB->Mysql, new_slogan,"abcdefghijk",11); Log(MSG_INFO,"[WS] New clan %s created, slogan detected=%s, cleaned=%s ",name,slogan,new_slogan); DB->QExecute( "INSERT into list_clan (logo,back,name,cp,grade,slogan,news) values (%i,%i,'%s',0,1,'%s','')",icon,background,name,new_slogan); thisclient->Clan->clanid = mysql_insert_id(DB->Mysql); thisclient->Clan->clanrank = 6; thisclient->Clan->logo = icon; thisclient->Clan->back = background; strncpy(thisclient->Clan->clanname,name,16); thisclient->Clan->grade = 1; //Update user clan information DB->QExecute( "UPDATE characters set clanid=%i,clan_rank=6 where id=%i", thisclient->Clan->clanid,thisclient->CharInfo->charid); //load clan info in char server BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0xfa ); //action to update clan informacion (charserver) ADDWORD ( pak, thisclient->Clan->clanid ); ADDWORD ( pak, thisclient->CharInfo->charid ); ADDWORD ( pak, thisclient->clientid ); cryptPacket( (char*)&pak, cct ); send( csock, (char*)&pak, pak.Size, 0 ); //Send to other players RESETPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 ); ADDWORD ( pak, thisclient->clientid ); ADDWORD ( pak, 0x081b );//??? ADDWORD ( pak, 0x0000 );//??? ADDWORD ( pak, background ); ADDWORD ( pak, icon ); ADDBYTE ( pak, 0x01 );//clan grade ADDBYTE ( pak, 0x06 );//clan rank ADDSTRING ( pak, name ); ADDBYTE ( pak, 0x00 ); SendToVisible( &pak, thisclient ); return true; }
// Clan Manager bool CWorldServer::pakClanManager ( CPlayer* thisclient, CPacket* P ) { int action = GETBYTE((*P),0); switch(action) { case 0xf0: { MYSQL_ROW row; int charid = GETWORD((*P),1); int clanid = GETWORD((*P),3); CPlayer* otherclient = GetClientByCID ( charid ); if(otherclient==NULL) return true; MYSQL_RES *result = DB->QStore("SELECT logo,back,name,grade FROM list_clan where id=%i", clanid); if(result==NULL) return true; if(mysql_num_rows(result)!=1) { Log(MSG_WARNING, "Invalid clan %i", clanid ); DB->QFree( ); return true; } row = mysql_fetch_row(result); otherclient->Clan->logo = atoi(row[0]); otherclient->Clan->back = atoi(row[1]); strcpy(otherclient->Clan->clanname,row[2]); otherclient->Clan->grade = atoi(row[3]); DB->QFree( ); BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 );//funcion ADDWORD ( pak, otherclient->clientid );//cleint id ADDWORD ( pak, clanid );//? ADDWORD ( pak, 0x0000 );//? ADDWORD ( pak, otherclient->Clan->back );//? ADDWORD ( pak, otherclient->Clan->logo );//? ADDBYTE ( pak, otherclient->Clan->grade ); ADDBYTE ( pak, otherclient->Clan->clanrank); ADDSTRING ( pak, otherclient->Clan->clanname ); ADDBYTE ( pak, 0x00 ); SendToVisible( &pak, otherclient ); Log(MSG_INFO,"[WS] pakClanManager 0x7e0, case 0xf0 (new member too?) %s",otherclient->CharInfo->charname); } case 0xfa://new member added { MYSQL_ROW row; int charid = GETWORD((*P),1); int clanid = GETWORD((*P),3); CPlayer* otherclient = GetClientByCID ( charid ); if(otherclient==NULL) return true; MYSQL_RES *result = DB->QStore("SELECT logo,back,name,grade FROM list_clan where id=%i", clanid); if(result==NULL) return true; if(mysql_num_rows(result)!=1) { Log(MSG_WARNING, "Invalid clan %i", clanid ); DB->QFree( ); return true; } row = mysql_fetch_row(result); otherclient->Clan->logo = atoi(row[0]); otherclient->Clan->back = atoi(row[1]); strcpy(otherclient->Clan->clanname,row[2]); otherclient->Clan->grade = atoi(row[3]); DB->QFree( ); otherclient->Clan->clanid=clanid; otherclient->Clan->clanrank=1; BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 );//funcion ADDWORD ( pak, otherclient->clientid );//cleint id ADDWORD ( pak, clanid );//? ADDWORD ( pak, 0x0000 );//? ADDWORD ( pak, otherclient->Clan->back );//? ADDWORD ( pak, otherclient->Clan->logo );//? ADDBYTE ( pak, otherclient->Clan->grade ); ADDBYTE ( pak, otherclient->Clan->clanrank ); ADDSTRING ( pak, otherclient->Clan->clanname ); ADDBYTE ( pak, 0x00 ); SendToVisible( &pak, otherclient ); Log(MSG_INFO,"[WS] pakClanManager 0x7e0, new member %s",otherclient->CharInfo->charname); } break; case 0xfb://Member Kicked { char nick[30]; memcpy( nick, &P->Buffer[1], P->Size ); CPlayer* otherclient = GetClientByCharName( nick ); if(otherclient!=NULL) { otherclient->Clan->clanid=0; otherclient->Clan->clanrank=1; otherclient->Clan->back=0; otherclient->Clan->logo=0; otherclient->Clan->grade=0; strcpy(otherclient->Clan->clanname,""); BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 ); ADDWORD ( pak, otherclient->clientid ); ADDQWORD ( pak, 0 ); ADDWORD ( pak, 0x0001 ); SendToVisible( &pak, otherclient ); Log(MSG_INFO,"[WS] pakClanManager 0x7e0, member kicked, %s",nick); } } break; case 0xfc://member change rank { char nick[30]; int newrank = GETBYTE((*P),1); memcpy( nick, &P->Buffer[2], P->Size ); CPlayer* otherclient = GetClientByCharName( nick ); if(otherclient!=NULL) { otherclient->Clan->clanrank = newrank; Log(MSG_INFO,"[WS] pakClanManager 0x7e0, change rank for %s to %i",nick,newrank); } } break; case 0xfd://disorg { unsigned int clanid = GETWORD((*P),1); unsigned int charid = GETWORD((*P),3); CPlayer* tclient = GetClientByCID( charid ); if(tclient==NULL) return true; tclient->Clan->clanid = 0; tclient->Clan->clanrank = 1; tclient->Clan->grade = 0; tclient->Clan->back = 0; tclient->Clan->logo = 0; memset( &tclient->Clan->clanname, '\0', 17 ); BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 ); ADDWORD ( pak, tclient->clientid ); ADDQWORD ( pak, 0 ); ADDWORD ( pak, 0x0001 ); SendToVisible( &pak, tclient ); Log(MSG_INFO,"[WS] pakClanManager 0x7e0, disorg"); } break; case 0xfe://Member Leave { char nick[17]; memcpy( nick, &P->Buffer[1], P->Size ); CPlayer* otherclient = GetClientByCharName(nick); if(otherclient!=NULL) { otherclient->Clan->clanid=0; otherclient->Clan->clanrank=0; otherclient->Clan->back=0; otherclient->Clan->logo=0; otherclient->Clan->grade=0; strcpy(otherclient->Clan->clanname,""); BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 ); ADDWORD ( pak, otherclient->clientid ); ADDQWORD ( pak, 0 ); ADDWORD ( pak, 0x0001 ); SendToVisible( &pak, otherclient ); Log(MSG_INFO,"[WS] pakClanManager 0x7e0, member left"); } } break; case 0xff: // update clan mark { unsigned int clanid = GETWORD((*P),1); unsigned int clanlogo = GETDWORD((*P), 3 ); for(unsigned int i=0;i<ClientList.size();i++) { if(ClientList.at(i)->player==NULL) continue; CPlayer* player = (CPlayer*)ClientList.at(i)->player; if(player->Clan->clanid==clanid) { player->Clan->back = 0; player->Clan->logo = clanlogo; BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 );//funcion ADDWORD ( pak, player->clientid );//cleint id ADDWORD ( pak, clanid );//? ADDWORD ( pak, 0x0000 );//? ADDWORD ( pak, player->Clan->back );//? ADDWORD ( pak, player->Clan->logo );//? ADDBYTE ( pak, player->Clan->grade ); ADDBYTE ( pak, player->Clan->clanrank ); ADDSTRING ( pak, player->Clan->clanname ); ADDBYTE ( pak, 0x00 ); SendToVisible( &pak, player ); Log(MSG_INFO,"[WS] pakClanManager 0x7e0, update clan mark"); } } } break; default: Log( MSG_INFO, "Clan manager unknown action %i", action ); } return true; }