int GameClient::LoadItemData() { for (int i = 0; i < NTL_MAX_COUNT_USER_HAVE_INVEN_ITEM; ++i) { ItemProfile[i].handle = INVALID_HOBJECT; ItemProfile[i].tblidx = INVALID_TBLIDX; } int count = 0; if (pServer->ServerDB->ExecuteSelect("SELECT * FROM `inventory` WHERE `CharID`='%u';", this->CurrCharID)) { while (pServer->ServerDB->Fetch()) { ItemProfile[count].handle = pServer->ServerDB->getInt("ID"); ItemProfile[count].tblidx = pServer->ServerDB->getInt("ItemID"); ItemProfile[count].byPlace = pServer->ServerDB->getInt("Place"); ItemProfile[count].byPos = pServer->ServerDB->getInt("Slot"); ItemProfile[count].byStackcount = pServer->ServerDB->getInt("Stack"); ItemProfile[count].byRank = pServer->ServerDB->getInt("Rank"); ItemProfile[count].byCurDur = pServer->ServerDB->getInt("CurDur"); ItemProfile[count].bNeedToIdentify = pServer->ServerDB->getBoolean("NeedToIdentify"); ItemProfile[count].byGrade = pServer->ServerDB->getInt("Grade"); ItemProfile[count].byBattleAttribute = pServer->ServerDB->getInt("BattleAttribute"); ItemProfile[count].byRestrictType = pServer->ServerDB->getInt("RestrictType"); memcpy(ItemProfile[count].awchMaker, charToWChar(pServer->ServerDB->getString("Maker")), NTL_MAX_SIZE_CHAR_NAME_UNICODE); ItemProfile[count].aOptionTblidx[0] = pServer->ServerDB->getInt("Opt1"); ItemProfile[count].aOptionTblidx[1] = pServer->ServerDB->getInt("Opt2"); ItemProfile[count].byDurationType = pServer->ServerDB->getInt("DurationType"); ItemProfile[count].nUseStartTime = pServer->ServerDB->getInt("UseStartTime"); ItemProfile[count].nUseEndTime = pServer->ServerDB->getInt("UseEndTime"); count++; } } return count; }
void CharClient::SendServerlist(bool one) { for (int i = 0; i < pServer->ServerCfg->GetInt("ServerCount"); i++) { char snode[20]; sprintf_s(snode, "Server%d", i + 1); sCU_SERVER_FARM_INFO sinfo; memset(&sinfo, 0, sizeof(sCU_SERVER_FARM_INFO)); sinfo.wOpCode = CU_SERVER_FARM_INFO; sinfo.serverFarmInfo.serverFarmId = i; memcpy(sinfo.serverFarmInfo.wszGameServerFarmName, charToWChar(pServer->ServerCfg->GetStr(snode, "Name")), NTL_MAX_SIZE_SERVER_FARM_NAME_UNICODE); sinfo.serverFarmInfo.byServerStatus = DBO_SERVER_STATUS_UP; sinfo.serverFarmInfo.dwLoad = 0; sinfo.serverFarmInfo.dwMaxLoad = pServer->ServerCfg->GetInt(snode, "MaxLoad"); Send((unsigned char*)&sinfo, sizeof(sinfo)); } if (one) { sCU_CHARACTER_SERVERLIST_ONE_RES slone; memset(&slone, 0, sizeof(sCU_CHARACTER_SERVERLIST_ONE_RES)); slone.wOpCode = CU_CHARACTER_SERVERLIST_ONE_RES; slone.wResultCode = CHARACTER_SUCCESS; Send((unsigned char*)&slone, sizeof(slone)); } else { sCU_CHARACTER_SERVERLIST_RES slres; memset(&slres, 0, sizeof(slres)); slres.wOpCode = CU_CHARACTER_SERVERLIST_RES; slres.wResultCode = CHARACTER_SUCCESS; Send((unsigned char*)&slres, sizeof(slres)); } }
void cLog::writeA(const std::string & buffer) { #ifdef _UNICODE write(charToWChar(buffer)); #else write(buffer); #endif }
void Texture::loadFromFile(std::string fileName) { ilGenImages(1, &imageId); ilBindImage(imageId); glGenTextures(1, &glTextureId); if (!ilLoadImage(charToWChar(fileName.c_str()))) { std::cout << "Couldn't load the image: " << fileName << " "; cout << ilGetError() << endl; } width = ilGetInteger(IL_IMAGE_WIDTH); height = ilGetInteger(IL_IMAGE_HEIGHT); }
void GameClient::LoadCharacterData() { if (pServer->ServerDB->ExecuteSelect("SELECT * FROM `character` WHERE `AccID`='%u' AND `ID`='%u';", AccountID, CurrCharID)) { while (pServer->ServerDB->Fetch()) { int Race = pServer->ServerDB->getInt("Race"); int Class = pServer->ServerDB->getInt("Class"); int Gender = pServer->ServerDB->getInt("Gender"); PCData pcdata = pServer->pcTblData->GetData(Race, Class, Gender); Logger::Log("Loaded PC TblInfo: Idx(%u) Race(%u) Class(%u) Gender(%u)\n", pcdata.TblIndex, pcdata.Race, pcdata.Class, pcdata.Gender); memset(&PcProfile, 0, sizeof(PcProfile)); memcpy(PcProfile.awchName, charToWChar(pServer->ServerDB->getString("Name")), NTL_MAX_SIZE_CHAR_NAME_UNICODE); memcpy(this->charName, charToWChar(pServer->ServerDB->getString("Name")), NTL_MAX_SIZE_CHAR_NAME_UNICODE); PcProfile.tblidx = pcdata.TblIndex; PcProfile.charId = pServer->ServerDB->getInt("ID"); this->isGameMaster = PcProfile.bIsGameMaster = pServer->ServerDB->getBoolean("IsGameMaster"); PcProfile.byLevel = pServer->ServerDB->getInt("Level"); PcProfile.dwCurExp = pServer->ServerDB->getInt("CurExp"); PcProfile.bIsAdult = pServer->ServerDB->getBoolean("Adult"); PcProfile.dwMaxExpInThisLevel = 100; PcProfile.dwTutorialHint = pServer->ServerDB->getInt("TutorialHint"); PcProfile.wCurEP = pServer->ServerDB->getInt("CurEP");; PcProfile.wCurLP = pServer->ServerDB->getInt("CurLP");; PcProfile.wCurRP = pcdata.Basic_RP; PcProfile.dwZenny = pServer->ServerDB->getInt("Money"); PcProfile.sMarking.byCode = INVALID_MARKING_TYPE; PcProfile.avatarAttribute.wBaseMaxEP = pServer->ServerDB->getInt("MaxEP"); PcProfile.avatarAttribute.wBaseMaxLP = pServer->ServerDB->getInt("MaxLP"); PcProfile.avatarAttribute.wBaseMaxRP = pcdata.Basic_RP; PcProfile.avatarAttribute.byBaseStr = pcdata.Str; PcProfile.avatarAttribute.byBaseFoc = pcdata.Foc; PcProfile.avatarAttribute.byBaseSol = pcdata.Sol; PcProfile.avatarAttribute.byBaseDex = pcdata.Dex; PcProfile.avatarAttribute.byBaseCon = pcdata.Con; PcProfile.avatarAttribute.byBaseEng = pcdata.Eng; PcProfile.avatarAttribute.fBaseAttackRange = pcdata.Attack_Range; PcProfile.avatarAttribute.wBaseAttackRate = pcdata.Attack_Rate; PcProfile.avatarAttribute.wBaseAttackSpeedRate = pcdata.Attack_Speed_Rate; PcProfile.avatarAttribute.wBaseBlockRate = pcdata.Block_Rate; PcProfile.avatarAttribute.wBaseCurseSuccessRate = pcdata.Curse_Success_Rate; PcProfile.avatarAttribute.wBaseCurseToleranceRate = pcdata.Curse_Tolerance_Rate; PcProfile.avatarAttribute.wBaseDodgeRate = pcdata.Dodge_Rate; PcProfile.avatarAttribute.fLastRunSpeed = (PcProfile.bIsAdult) ? pcdata.Adult_Run_Speed : pcdata.Child_Run_Speed; CalculateAtributes(&pcdata); PcProfile.sPcShape.byFace = pServer->ServerDB->getInt("Face"); PcProfile.sPcShape.byHair = pServer->ServerDB->getInt("Hair"); PcProfile.sPcShape.byHairColor = pServer->ServerDB->getInt("HairColor"); PcProfile.sPcShape.bySkinColor = pServer->ServerDB->getInt("SkinColor"); memset(&CharState, 0, sizeof(CharState)); CharState.sCharStateBase.dwConditionFlag = 0; CharState.sCharStateBase.bFightMode = false; CharState.sCharStateBase.byStateID = 0; CharState.sCharStateBase.dwStateTime = (DWORD)time(NULL); CharState.sCharStateBase.aspectState.sAspectStateBase.byAspectStateId = ASPECTSTATE_INVALID; CharState.sCharStateBase.aspectState.sAspectStateDetail.sGreatNamek.bySourceGrade = 0; CharState.sCharStateBase.aspectState.sAspectStateDetail.sKaioken.bySourceGrade = 0; CharState.sCharStateBase.aspectState.sAspectStateDetail.sPureMajin.bySourceGrade = 0; CharState.sCharStateBase.aspectState.sAspectStateDetail.sSuperSaiyan.bySourceGrade = 0; CharState.sCharStateBase.aspectState.sAspectStateDetail.sVehicle.idVehicleTblidx = 0; CharState.sCharStateBase.vCurLoc.x = pServer->ServerDB->getFloat("PositionX"); CharState.sCharStateBase.vCurLoc.y = pServer->ServerDB->getFloat("PositionY"); CharState.sCharStateBase.vCurLoc.z = pServer->ServerDB->getFloat("PositionZ"); CharState.sCharStateBase.vCurDir.x = pServer->ServerDB->getFloat("DirectionX"); CharState.sCharStateBase.vCurDir.y = pServer->ServerDB->getFloat("DirectionY"); CharState.sCharStateBase.vCurDir.z = pServer->ServerDB->getFloat("DirectionZ"); } } }
static char* unicodeToAnsi(const char * text){ wchar_t * wtext = charToWChar(text); return wCharToChar(wtext); }
void CharacterProfile::LoadCharacterData() { if (pServer->ServerDB->ExecuteSelect("SELECT * FROM `character` WHERE `AccID`='%u' AND `ID`='%u';", AccountID, hCharID)) { while (pServer->ServerDB->Fetch()) { memset(&sPcProfile, 0, sizeof(sPcProfile)); sPcProfile.charId = pServer->ServerDB->getInt("ID"); memcpy(sPcProfile.awchName, charToWChar(pServer->ServerDB->getString("Name")), NTL_MAX_SIZE_CHAR_NAME_UNICODE); memcpy(wszCharName, charToWChar(pServer->ServerDB->getString("Name")), NTL_MAX_SIZE_CHAR_NAME_UNICODE); byRace = pServer->ServerDB->getInt("Race"); byClass = pServer->ServerDB->getInt("Class"); byGender = pServer->ServerDB->getInt("Gender"); sPcProfile.byLevel = pServer->ServerDB->getInt("Level"); this->bIsGameMaster = sPcProfile.bIsGameMaster = pServer->ServerDB->getBoolean("IsGameMaster"); sPcProfile.dwCurExp = pServer->ServerDB->getInt("CurExp"); sPcProfile.bIsAdult = pServer->ServerDB->getBoolean("Adult"); sPcProfile.dwTutorialHint = pServer->ServerDB->getInt("TutorialHint"); sPcProfile.dwZenny = pServer->ServerDB->getInt("Money"); sPcProfile.sPcShape.byFace = pServer->ServerDB->getInt("Face"); sPcProfile.sPcShape.byHair = pServer->ServerDB->getInt("Hair"); sPcProfile.sPcShape.byHairColor = pServer->ServerDB->getInt("HairColor"); sPcProfile.sPcShape.bySkinColor = pServer->ServerDB->getInt("SkinColor"); sPcProfile.byBindType = pServer->ServerDB->getInt("BindType"); sPcProfile.bindObjectTblidx = pServer->ServerDB->getInt("bindObjectTblid"); sPcProfile.bindWorldId = pServer->ServerDB->getInt("bindWorldId"); sPcProfile.bChangeClass = pServer->ServerDB->getBoolean("ChangeClass"); sPcProfile.dwReputation = pServer->ServerDB->getInt("Reputation"); sPcProfile.dwMudosaPoint = pServer->ServerDB->getInt("MudosaPoint"); sPcProfile.dwSpPoint = pServer->ServerDB->getInt("SpPoint"); sPcProfile.sMarking.byCode = pServer->ServerDB->getInt("Marking"); sPcProfile.guildId = pServer->ServerDB->getInt("GuildID"); memset(&sCharState, 0, sizeof(sCharState)); sCharState.sCharStateBase.vCurLoc.x = pServer->ServerDB->getFloat("PositionX"); sCharState.sCharStateBase.vCurLoc.y = pServer->ServerDB->getFloat("PositionY"); sCharState.sCharStateBase.vCurLoc.z = pServer->ServerDB->getFloat("PositionZ"); sCharState.sCharStateBase.vCurDir.x = pServer->ServerDB->getFloat("DirectionX"); sCharState.sCharStateBase.vCurDir.y = pServer->ServerDB->getFloat("DirectionY"); sCharState.sCharStateBase.vCurDir.z = pServer->ServerDB->getFloat("DirectionZ"); sCharState.sCharStateBase.byStateID = CHARSTATE_SPAWNING; sCharState.sCharStateDetail.sCharStateSpawning.byTeleportType = TELEPORT_TYPE_GAME_IN; sCharState.sCharStateBase.dwConditionFlag = 0; sCharState.sCharStateBase.bFightMode = false; sCharState.sCharStateBase.byStateID = 0; sCharState.sCharStateBase.dwStateTime = (DWORD)time(NULL); sCharState.sCharStateBase.aspectState.sAspectStateBase.byAspectStateId = ASPECTSTATE_INVALID; sCharState.sCharStateBase.aspectState.sAspectStateDetail.sGreatNamek.bySourceGrade = 0; sCharState.sCharStateBase.aspectState.sAspectStateDetail.sKaioken.bySourceGrade = 0; sCharState.sCharStateBase.aspectState.sAspectStateDetail.sPureMajin.bySourceGrade = 0; sCharState.sCharStateBase.aspectState.sAspectStateDetail.sSuperSaiyan.bySourceGrade = 0; sCharState.sCharStateBase.aspectState.sAspectStateDetail.sVehicle.idVehicleTblidx = 0; sPC_TBLDAT* pPcTbl = (sPC_TBLDAT*)pServer->GetTableContainer()->GetPcTable()->GetPcTbldat(byRace, byClass, byGender); sEXP_TBLDAT* pExpTbl = (sEXP_TBLDAT*)pServer->GetTableContainer()->GetExpTable()->FindData(sPcProfile.byLevel); if (pPcTbl && pExpTbl) { sPcProfile.tblidx = pPcTbl->tblidx; sPcProfile.dwMaxExpInThisLevel = pExpTbl->dwNeed_Exp; sPcProfile.wCurEP = pPcTbl->wBasic_EP; sPcProfile.wCurLP = pPcTbl->wBasic_LP; sPcProfile.wCurRP = pPcTbl->wBasic_RP; sPcProfile.avatarAttribute.fLastRunSpeed = (sPcProfile.bIsAdult) ? pPcTbl->fAdult_Run_Speed : pPcTbl->fChild_Run_Speed; } } } }