📄 playerdata.cpp.svn-base
字号:
/*
Rose Online Server Emulator
Copyright (C) 2006,2007 OSRose Team http://www.osrose.net
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
depeloped with Main erose/hrose source server + some change from the original eich source
*/
#include "player.h"
#include "worldserver.h"
// Load this characters userdata from the database
bool CPlayer::loaddata( )
{
MYSQL_ROW row;
MYSQL_RES *result = GServer->DB->QStore("SELECT level,face,hairStyle,sex,classid,zuly,str,dex,_int, con,cha,sen,curHp,curMp,id,statp,skillp,exp,stamina,quickbar,basic_skills, class_skills,class_skills_level,respawnid,clanid,clan_rank,townid FROM characters WHERE char_name='%s'", CharInfo->charname);
if(result==NULL) return false;
if(mysql_num_rows(result)!=1)
{
Log( MSG_WARNING, "Number of user with charname '%s' is %i", CharInfo->charname,mysql_num_rows(result));
return false;
}
row = mysql_fetch_row(result);
Stats->Level = atoi(row[0]);
CharInfo->Face = atoi(row[1]);
CharInfo->Hair = atoi(row[2]);
CharInfo->Sex = atoi(row[3]);
CharInfo->Job = atoi(row[4]);
CharInfo->Zulies = atol(row[5]);
Attr->Str = atoi(row[6]);
Attr->Dex = atoi(row[7]);
Attr->Int = atoi(row[8]);
Attr->Con = atoi(row[9]);
Attr->Cha = atoi(row[10]);
Attr->Sen = atoi(row[11]);
Stats->HP = atoi(row[12]);
Stats->MP = atoi(row[13]);
CharInfo->charid = atoi(row[14]);
CharInfo->StatPoints = atoi(row[15]);
CharInfo->SkillPoints = atoi(row[16]);
CharInfo->Exp = atoi(row[17]);
CharInfo->stamina = atoi(row[18]);
Position->respawn = atoi(row[23]);
Clan->clanid = atoi(row[24]);
Clan->clanrank = atoi(row[25]);
Position->saved = atoi(row[26]);
p_skills = 0;
for(BYTE i=0;i<48;i++)
{
char* tmp=strtok((i==0?row[19]:NULL), ",");
if (tmp!=NULL)
quickbar[i]=atoi(tmp);
else
quickbar[i]=0;
}
for(UINT i=0;i<42;i++)
{
char* tmp=strtok((i==0?row[20]:NULL), ",");
if (tmp!=NULL)
bskills[i]=atoi(tmp);
else
bskills[i]=0;
}
for(UINT i=0;i<60;i++)
{
char* tmp=strtok((i==0?row[21]:NULL), ",");
if (tmp!=NULL)
{
if(atoi(tmp)!=0)
p_skills++;
cskills[i].id=atoi(tmp);
}
else
cskills[i].id=0;
}
for(UINT i=0;i<60;i++)
{
char* tmp=strtok((i==0?row[22]:NULL), ",");
if (tmp!=NULL)
cskills[i].level=atoi(tmp);
else
cskills[i].level=1;
}
for(int i=0;i<60;i++)
{
if(cskills[i].id==0)
{
cskills[i].thisskill = NULL;
}
else
{
cskills[i].thisskill = GServer->GetSkillByID( cskills[i].id+cskills[i].level-1 );
}
}
GServer->DB->QFree( );
result = GServer->DB->QStore("SELECT itemnum,itemtype,refine,durability,lifespan,slotnum,count,stats,socketed,appraised,gem FROM items WHERE owner=%i", CharInfo->charid);
if(result==NULL) return false;
while(row = mysql_fetch_row(result))
{
if(!GServer->IsValidItem( atoi(row[1]), atoi(row[0]) ) || atoi(row[6])==0)
{
Log(MSG_WARNING, "char %s have a invalid or empty item in inventory: %i-%i [%i], this item will be deleted", CharInfo->charname, atoi(row[1]), atoi(row[0]), atoi(row[6]) );
continue;
}
UINT itemnum = atoi(row[5]);
items[itemnum].itemnum = atoi(row[0]);
items[itemnum].itemtype = atoi(row[1]);
items[itemnum].refine = atoi(row[2]);
items[itemnum].durability = atoi(row[3]);
items[itemnum].lifespan = atoi(row[4]);
items[itemnum].count = atoi(row[6]);
items[itemnum].stats = atoi(row[7]);
items[itemnum].socketed = (atoi(row[8])==1)?true:false;
items[itemnum].appraised = (atoi(row[9])==1)?true:false;
items[itemnum].gem = atoi(row[10])>3999?0:atoi(row[10]);
}
GServer->DB->QFree( );
result = GServer->DB->QStore("SELECT itemnum,itemtype,refine,durability,lifespan,slotnum,count,stats,socketed,appraised,gem FROM storage WHERE owner=%i", Session->userid);
if(result==NULL) return false;
nstorageitems = mysql_num_rows(result);
while(row = mysql_fetch_row(result))
{
if(!GServer->IsValidItem( atoi(row[1]), atoi(row[0]) ) || atoi(row[6])==0)
{
Log(MSG_WARNING, "char %s have a invalid or empty item in storage: %i%i [%i], this item will be deleted", CharInfo->charname, atoi(row[1]), atoi(row[0]), atoi(row[6]) );
continue;
}
UINT itemnum = atoi(row[5]);
storageitems[itemnum].itemnum = atoi(row[0]);
storageitems[itemnum].itemtype = atoi(row[1]);
storageitems[itemnum].refine = atoi(row[2]);
storageitems[itemnum].durability = atoi(row[3]);
storageitems[itemnum].lifespan = atoi(row[4]);
storageitems[itemnum].count = atoi(row[6]);
storageitems[itemnum].stats = atoi(row[7]);
storageitems[itemnum].socketed = (atoi(row[8])==1)?true:false;
storageitems[itemnum].appraised = (atoi(row[9])==1)?true:false;
storageitems[itemnum].gem = atoi(row[10]);
}
GServer->DB->QFree( );
if(Clan->clanid!=0)
{
result = GServer->DB->QStore("SELECT logo,back,name,grade FROM list_clan where id=%i", Clan->clanid);
if(result==NULL) return false;
if(mysql_num_rows(result)!=1)
{
Log(MSG_WARNING, "There are %i clan(s) with id %i", mysql_num_rows(result), Clan->clanid );
Clan->clanid=0;
}
else
{
row = mysql_fetch_row(result);
Clan->logo = atoi(row[0]);
Clan->back = atoi(row[1]);
strcpy(Clan->clanname,row[2]);
Clan->grade = atoi(row[3]);
}
GServer->DB->QFree( );
}
for (int i=0;i<25;i++)
{
QuestVariables[i]=0x00;
}
//LMA begin
//20070621-211100
//Patch for soul crystal quest...
result = GServer->DB->QStore("SELECT questid, active from list_quest where owner=%i and questid>208 and questid<218",CharInfo->charid );
if(result!=NULL)
{
bool tryteh_done=false;
bool spero_time=false;
while(row = mysql_fetch_row(result))
{
switch (atoi(row[0]))
{
case 209:
{
QuestVariables[1]=0x06;
}
break;
case 210:
{
QuestVariables[1]=0x07;
}
break;
case 211:
{
QuestVariables[1]=0x08;
}
break;
case 215:
{
spero_time=true;
}
break;
case 217:
{
tryteh_done=true;
}
break;
default:
break;
}
}
GServer->DB->QFree( );
if (tryteh_done||(!spero_time))
{
QuestVariables[1]=0x00;
}
}
//LMA END
//LMA BEGIN
//20060623, 022000
//Patch for Lunar Quest
bool is_lunar=false;
//LMA END
result = GServer->DB->QStore("SELECT questid,nitems,active from list_quest where owner=%i order by active DESC",CharInfo->charid );
if(result==NULL) return false;
while(row = mysql_fetch_row(result))
{
int questid = atoi(row[0]);
CQuest* thisquest = GServer->GetQuestByID( questid );
if(thisquest==0)
continue;
//LMA BEGIN
//20060623, 022000
//Patch for Lunar Quest
//Log( MSG_INFO, "Reading quest %u",thisquest->id);
if (thisquest->id==808&&atoi(row[2]))
{
Log( MSG_INFO, "Patch Lunar part 1");
is_lunar=true;
continue;
}
//LMA END
QUESTS* myquest = new QUESTS;
assert(myquest);
myquest->questid = thisquest->questid;
myquest->thisquest = thisquest;
for(int i=0;i<5;i++)
{
char* tmp = strtok((i==0?row[1]:NULL),"|");
if(tmp!=NULL)
myquest->items[i] = atoi(tmp);
else
myquest->items[i] = 0;
}
//LMA BEGIN
//20070621-215100
//Various patches for the quests...
//Patch for Spero quest
if (thisquest->id==2000)
{
myquest->items[0]=0;
myquest->items[1]=0;
if (myquest->items[2]==1)
{
myquest->items[0]=1;
}
if (myquest->items[2]==2)
{
myquest->items[0]=1;
myquest->items[1]=1;
}
}
//Patch for hunt for pomics
if (thisquest->id==224||thisquest->id==226)
{
myquest->items[0]=0;
myquest->items[1]=0;
}
//Patch for Ikaness
if (thisquest->id==232)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -