void BattleCharacter::LevelUp(int nUp) { //从角色数据文件中获取升级数据,将他们附加到角色上 m_nLevel += nUp; int nAtrUp;//上升的属性 CharacterDataLoader* pData = CharacterDataLoader::instance(); pData->GetCharacterValue(DATA_CHARACTER_HP_PLUS,GetCharID(),&nAtrUp); m_nMaxHP +=nAtrUp*nUp; pData->GetCharacterValue(DATA_CHARACTER_SPD_PLUS,GetCharID(),&nAtrUp); m_nSpd += nAtrUp*nUp; pData->GetCharacterValue(DATA_CHARACTER_DEX_PLUS,GetCharID(),&nAtrUp); m_nDex += nAtrUp*nUp; pData->GetCharacterValue(DATA_CHARACTER_LUK_PLUS,GetCharID(),&nAtrUp); m_nLuk += nAtrUp*nUp; pData->GetCharacterValue(DATA_CHARACTER_STR_PLUS,GetCharID(),&nAtrUp); m_nStr += nAtrUp*nUp; pData->GetCharacterValue(DATA_CHARACTER_DEF_PLUS,GetCharID(),&nAtrUp); m_nDef += nAtrUp*nUp; //获取该等级的技能、能力 pData->GetLevelAbilities(m_nCharID,m_nLevel,m_vAbilities); pData->GetLevelSkills(m_nCharID,m_nLevel,m_vSkills); }
void Client::EnterWorld(bool TryBootup) { if (zoneID == 0) return; ZoneServer* zs = nullptr; if(instanceID > 0) { if(database.VerifyInstanceAlive(instanceID, GetCharID())) { if(database.VerifyZoneInstance(zoneID, instanceID)) { zs = zoneserver_list.FindByInstanceID(instanceID); } else { instanceID = 0; zs = nullptr; database.MoveCharacterToBind(GetCharID()); ZoneUnavail(); return; } } else { instanceID = 0; zs = nullptr; database.MoveCharacterToBind(GetCharID()); ZoneUnavail(); return; } } else zs = zoneserver_list.FindByZoneID(zoneID); const char *zone_name=database.GetZoneName(zoneID, true); if (zs) { // warn the world we're comming, so it knows not to shutdown zs->IncommingClient(this); } else { if (TryBootup) { clog(WORLD__CLIENT,"Attempting autobootup of %s (%d:%d)",zone_name,zoneID,instanceID); autobootup_timeout.Start(); pwaitingforbootup = zoneserver_list.TriggerBootup(zoneID, instanceID); if (pwaitingforbootup == 0) { clog(WORLD__CLIENT_ERR,"No zoneserver available to boot up."); ZoneUnavail(); } return; } else { clog(WORLD__CLIENT_ERR,"Requested zone %s is no running.",zone_name); ZoneUnavail(); return; } } pwaitingforbootup = 0; cle->SetChar(charid, char_name); database.UpdateLiveChar(char_name, GetAccountID()); clog(WORLD__CLIENT,"%s %s (%d:%d)",seencharsel ? "Entering zone" : "Zoning to",zone_name,zoneID,instanceID); // database.SetAuthentication(account_id, char_name, zone_name, ip); if (seencharsel) { if (GetAdmin() < 80 && zoneserver_list.IsZoneLocked(zoneID)) { clog(WORLD__CLIENT_ERR,"Enter world failed. Zone is locked."); ZoneUnavail(); return; } ServerPacket* pack = new ServerPacket; pack->opcode = ServerOP_AcceptWorldEntrance; pack->size = sizeof(WorldToZone_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); WorldToZone_Struct* wtz = (WorldToZone_Struct*) pack->pBuffer; wtz->account_id = GetAccountID(); wtz->response = 0; zs->SendPacket(pack); delete pack; } else { // if they havent seen character select screen, we can assume this is a zone // to zone movement, which should be preauthorized before they leave the previous zone Clearance(1); } }
bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { if (GetAccountID() == 0) { clog(WORLD__CLIENT_ERR,"Enter world with no logged in account"); eqs->Close(); return true; } if(GetAdmin() < 0) { clog(WORLD__CLIENT,"Account banned or suspended."); eqs->Close(); return true; } if (RuleI(World, MaxClientsPerIP) >= 0) { client_list.GetCLEIP(this->GetIP()); //Check current CLE Entry IPs against incoming connection } EnterWorld_Struct *ew=(EnterWorld_Struct *)app->pBuffer; strn0cpy(char_name, ew->name, 64); EQApplicationPacket *outapp; uint32 tmpaccid = 0; charid = database.GetCharacterInfo(char_name, &tmpaccid, &zoneID, &instanceID); if (charid == 0 || tmpaccid != GetAccountID()) { clog(WORLD__CLIENT_ERR,"Could not get CharInfo for '%s'",char_name); eqs->Close(); return true; } // Make sure this account owns this character if (tmpaccid != GetAccountID()) { clog(WORLD__CLIENT_ERR,"This account does not own the character named '%s'",char_name); eqs->Close(); return true; } if(!pZoning && ew->return_home && !ew->tutorial) { CharacterSelect_Struct* cs = new CharacterSelect_Struct; memset(cs, 0, sizeof(CharacterSelect_Struct)); database.GetCharSelectInfo(GetAccountID(), cs); bool home_enabled = false; for(int x = 0; x < 10; ++x) { if(strcasecmp(cs->name[x], char_name) == 0) { if(cs->gohome[x] == 1) { home_enabled = true; break; } } } safe_delete(cs); if(home_enabled) { zoneID = database.MoveCharacterToBind(charid,4); } else { clog(WORLD__CLIENT_ERR,"'%s' is trying to go home before they're able...",char_name); database.SetHackerFlag(GetAccountName(), char_name, "MQGoHome: player tried to go home before they were able."); eqs->Close(); return true; } } if(!pZoning && (RuleB(World, EnableTutorialButton) && (ew->tutorial || StartInTutorial))) { CharacterSelect_Struct* cs = new CharacterSelect_Struct; memset(cs, 0, sizeof(CharacterSelect_Struct)); database.GetCharSelectInfo(GetAccountID(), cs); bool tutorial_enabled = false; for(int x = 0; x < 10; ++x) { if(strcasecmp(cs->name[x], char_name) == 0) { if(cs->tutorial[x] == 1) { tutorial_enabled = true; break; } } } safe_delete(cs); if(tutorial_enabled) { zoneID = RuleI(World, TutorialZoneID); database.MoveCharacterToZone(charid, database.GetZoneName(zoneID)); } else { clog(WORLD__CLIENT_ERR,"'%s' is trying to go to tutorial but are not allowed...",char_name); database.SetHackerFlag(GetAccountName(), char_name, "MQTutorial: player tried to enter the tutorial without having tutorial enabled for this character."); eqs->Close(); return true; } } if (zoneID == 0 || !database.GetZoneName(zoneID)) { // This is to save people in an invalid zone, once it's removed from the DB database.MoveCharacterToZone(charid, "arena"); clog(WORLD__CLIENT_ERR, "Zone not found in database zone_id=%i, moveing char to arena character:%s", zoneID, char_name); } if(instanceID > 0) { if(!database.VerifyInstanceAlive(instanceID, GetCharID())) { zoneID = database.MoveCharacterToBind(charid); instanceID = 0; } else { if(!database.VerifyZoneInstance(zoneID, instanceID)) { zoneID = database.MoveCharacterToBind(charid); instanceID = 0; } } } if(!pZoning) { database.SetGroupID(char_name, 0, charid); database.SetFirstLogon(charid, 1); if (RuleB(World, AnnounceJoinQuits) == true) //this is having an issue, its not taking a true false swap, only takes default. { zoneserver_list.SendEmoteMessage(0, 0, 0, 15, "%s is logging on!", GetCharName()); clog(WORLD__CLIENT_ERR, "Character is logging on: %s", GetCharName()); } } else{ uint32 groupid=database.GetGroupID(char_name); if(groupid>0){ char* leader=0; char leaderbuf[64]={0}; if((leader=database.GetGroupLeaderForLogin(char_name,leaderbuf)) && strlen(leader)>1){ EQApplicationPacket* outapp3 = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct)); GroupJoin_Struct* gj=(GroupJoin_Struct*)outapp3->pBuffer; gj->action=8; strcpy(gj->yourname,char_name); strcpy(gj->membername,leader); QueuePacket(outapp3); safe_delete(outapp3); } } } outapp = new EQApplicationPacket(OP_MOTD); char tmp[500] = {0}; if (database.GetVariable("MOTD", tmp, 500)) { outapp->size = strlen(tmp)+1; outapp->pBuffer = new uchar[outapp->size]; memset(outapp->pBuffer,0,outapp->size); strcpy((char*)outapp->pBuffer, tmp); } else { // Null Message of the Day. :) outapp->size = 1; outapp->pBuffer = new uchar[outapp->size]; outapp->pBuffer[0] = 0; } QueuePacket(outapp); safe_delete(outapp); int MailKey = MakeRandomInt(1, INT_MAX); database.SetMailKey(charid, GetIP(), MailKey); char ConnectionType; ConnectionType = 'C'; EQApplicationPacket *outapp2 = new EQApplicationPacket(OP_SetChatServer); char buffer[112]; const WorldConfig *Config = WorldConfig::get(); sprintf(buffer,"%s,%i,%s.%s,%c%08X", Config->ChatHost.c_str(), Config->ChatPort, Config->ShortName.c_str(), this->GetCharName(), ConnectionType, MailKey ); outapp2->size=strlen(buffer)+1; outapp2->pBuffer = new uchar[outapp2->size]; memcpy(outapp2->pBuffer,buffer,outapp2->size); QueuePacket(outapp2); safe_delete(outapp2); EnterWorld(); return true; }
//By Luiz45 Update Money in Database void CharacterProfile::UpdateMoneyDataBase() { pServer->ServerDB->ExecuteQuery("UPDATE `character` SET `Money`='%u' WHERE `ID`='%u' AND `AccID`='%u'",sPcProfile.dwZenny,GetCharID(),GetAccountid()); }
//By Luiz45 Remove Item From Inventory and Delete from DB void CharacterProfile::RemoveItemFromInventory(HOBJECT hItem) { for (int i = 0; i < NTL_MAX_COUNT_USER_HAVE_INVEN_ITEM; i++) { if (asItemProfile[i].handle == hItem) { asItemProfile[i].handle = INVALID_HOBJECT; asItemProfile[i].byStackcount = 255; asItemProfile[i].bNeedToIdentify = false; asItemProfile[i].tblidx = INVALID_TBLIDX; asItemProfile[i].byPlace = 255; asItemProfile[i].byPos = 255; pServer->ServerDB->ExecuteQuery("DELETE FROM `inventory` WHERE `CharID`='%u' AND `ItemSerialID`='%u'", GetCharID(), hItem); break; } } }
//By Luiz45 update Stack Count in DB and in Inventory void CharacterProfile::UpdateStackCount(HOBJECT hItem, BYTE byStackCount) { for (int i = 0; i < NTL_MAX_COUNT_USER_HAVE_INVEN_ITEM; i++) { if (asItemProfile[i].handle == hItem) { asItemProfile[i].byStackcount = byStackCount; pServer->ServerDB->ExecuteQuery("UPDATE `inventory` Set `Stack` = '%u' WHERE `CharID`='%u' AND `ItemSerialID`='%u'", byStackCount, GetCharID(), hItem); break; } } }
//By Luiz45 he will update Skill in the DBase and in our asSkillInfo list void CharacterProfile::UpdateSkill(TBLIDX tblBefore, TBLIDX tblNext) { pServer->ServerDB->ExecuteQuery("UPDATE `skills` Set `SkillID`='%u' WHERE `SkillID`='%u' AND `CharID`='%u';", tblNext,tblBefore, GetCharID()); pServer->ServerDB->ExecuteQuery("UPDATE `character` Set `SpPoint`='%u' WHERE `CharID`='%u';", sPcProfile.dwSpPoint, GetCharID()); for (int i = 0; i < NTL_MAX_PC_HAVE_SKILL; i++) { if (asSkillInfo[i].tblidx == tblBefore) { asSkillInfo[i].tblidx = tblNext; return; } } }
bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { if (GetAccountID() == 0) { clog(WORLD__CLIENT_ERR,"Enter world with no logged in account"); eqs->Close(); return true; } if(GetAdmin() < 0) { clog(WORLD__CLIENT,"Account banned or suspended."); eqs->Close(); return true; } if (RuleI(World, MaxClientsPerIP) >= 0) { client_list.GetCLEIP(this->GetIP()); //Check current CLE Entry IPs against incoming connection } EnterWorld_Struct *ew=(EnterWorld_Struct *)app->pBuffer; strn0cpy(char_name, ew->name, 64); EQApplicationPacket *outapp; uint32 tmpaccid = 0; charid = database.GetCharacterInfo(char_name, &tmpaccid, &zoneID, &instanceID); if (charid == 0 || tmpaccid != GetAccountID()) { clog(WORLD__CLIENT_ERR,"Could not get CharInfo for '%s'",char_name); eqs->Close(); return true; } // Make sure this account owns this character if (tmpaccid != GetAccountID()) { clog(WORLD__CLIENT_ERR,"This account does not own the character named '%s'",char_name); eqs->Close(); return true; } if (zoneID == 0 || !database.GetZoneName(zoneID)) { // This is to save people in an invalid zone, once it's removed from the DB database.MoveCharacterToZone(charid, "arena"); clog(WORLD__CLIENT_ERR, "Zone not found in database zone_id=%i, moveing char to arena character:%s", zoneID, char_name); } if(instanceID > 0) { if(!database.VerifyInstanceAlive(instanceID, GetCharID())) { zoneID = database.MoveCharacterToBind(charid); instanceID = 0; } else { if(!database.VerifyZoneInstance(zoneID, instanceID)) { zoneID = database.MoveCharacterToBind(charid); instanceID = 0; } } } if(!pZoning) { database.SetGroupID(char_name, 0, charid); database.SetFirstLogon(charid, 1); } else{ uint32 groupid = database.GetGroupID(char_name); if(groupid > 0){ char* leader = 0; char leaderbuf[64] = {0}; if((leader = database.GetGroupLeaderForLogin(char_name, leaderbuf)) && strlen(leader)>1){ EQApplicationPacket* outapp3 = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct)); GroupJoin_Struct* gj=(GroupJoin_Struct*)outapp3->pBuffer; gj->action=8; strcpy(gj->yourname, char_name); strcpy(gj->membername, leader); QueuePacket(outapp3); safe_delete(outapp3); } } } outapp = new EQApplicationPacket(OP_MOTD); char tmp[500] = {0}; if (database.GetVariable("MOTD", tmp, 500)) { outapp->size = strlen(tmp)+1; outapp->pBuffer = new uchar[outapp->size]; memset(outapp->pBuffer,0,outapp->size); strcpy((char*)outapp->pBuffer, tmp); } else { // Null Message of the Day. :) outapp->size = 1; outapp->pBuffer = new uchar[outapp->size]; outapp->pBuffer[0] = 0; } QueuePacket(outapp); safe_delete(outapp); int MailKey = emu_random.Int(1, INT_MAX); database.SetMailKey(charid, GetIP(), MailKey); char ConnectionType; ConnectionType = 'C'; EQApplicationPacket *outapp2 = new EQApplicationPacket(OP_SetChatServer); char buffer[112]; const WorldConfig *Config = WorldConfig::get(); sprintf(buffer,"%s,%i,%s.%s,%c%08X", Config->ChatHost.c_str(), Config->ChatPort, Config->ShortName.c_str(), this->GetCharName(), ConnectionType, MailKey ); outapp2->size=strlen(buffer)+1; outapp2->pBuffer = new uchar[outapp2->size]; memcpy(outapp2->pBuffer,buffer,outapp2->size); QueuePacket(outapp2); safe_delete(outapp2); EnterWorld(); return true; }