⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 startup.cpp.svn-base

📁 ROSE的源代码。了解的自己研究,编译通过
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
/*
    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 "worldserver.h"


bool CWorldServer::LoadNPCData( )
{
	Log( MSG_LOAD, "NPC Data           " );    
	MYSQL_ROW row;    
	MYSQL_RES *result = DB->QStore("SELECT id,life,walkspeed,runspeed,drivespeed,weapon, subweapon,level,hp,attackpower,hitpower,defense,strength,evasion,attackspeed,AI,exp,dropid,money,item,tab1,tab2,tab3,specialtab,attackdistance,aggresive,shp,dialog FROM npc_data order by id");
    if(result==NULL) return false;
	while( row = mysql_fetch_row(result) )
    {
        CNPCData* newnpc = new (nothrow) CNPCData;
        if(newnpc==NULL)
        {
            Log( MSG_ERROR, "Error allocing memory" );
            continue;
        }
        newnpc->id = atoi(row[0]);
        newnpc->life = atoi(row[1]);
        newnpc->wspeed = atoi(row[2]);
        newnpc->rspeed = atoi(row[3]);
        newnpc->dspeed = atoi(row[4]);
        newnpc->weapon = atoi(row[5]);
        newnpc->subweapon = atoi(row[6]);
        newnpc->level = atoi(row[7]);
        newnpc->hp = atoi(row[8]);
        newnpc->atkpower = atoi(row[9]);
        newnpc->hitrate = atoi(row[10]);
        newnpc->defense = atoi(row[11]);
        newnpc->magicdefense = atoi(row[12]);
        newnpc->dodge = atoi(row[13]);
        newnpc->atkspeed = atof(row[14]);
        newnpc->AI = atoi(row[15]);
        newnpc->exp = atoi(row[16]);
        newnpc->dropid = atoi(row[17]);
        newnpc->money = atoi(row[18]);
        newnpc->item = atoi(row[19]);
        newnpc->tab1 = atoi(row[20]);
        newnpc->tab2 = atoi(row[21]);
        newnpc->tab3 = atoi(row[22]);
        newnpc->specialtab = atoi(row[23]);
        newnpc->atkdistance = atof(row[24])/100;
        newnpc->aggresive = atoi(row[25]);
        newnpc->shp = atoi(row[26]);  
        newnpc->dialogid = atoi(row[27]);  
        NPCData.push_back( newnpc );
    }     
	DB->QFree( );	
	return true;	
}

bool CWorldServer::LoadSkillData( )
{
	Log( MSG_LOAD, "Skills data            " );    
	MYSQL_ROW row;    
	MYSQL_RES *result = DB->QStore("SELECT id,level,sp,type,range,target,power,duration,mp, success,weapon,class,rskills,lskills,buff1,buffv11,buffv12, buff2,buffv21,buffv22,buff3,buffv31,buffv32,clevel,aoe,aoeradius,script,value1 FROM skills_data order by id");
    if(result==NULL) return false;
	while( row = mysql_fetch_row(result) )
    {
        CSkills* newskill = new (nothrow) CSkills;
        if(newskill==NULL)
        {
            Log(MSG_ERROR, "Error allocing memory" );
            DB->QFree( );
            return false;
        }
        newskill->id=atoi(row[0]);
        newskill->level=atoi(row[1]);
        newskill->sp=atoi(row[2]);  
        newskill->type=atoi(row[3]);
        newskill->range=atoi(row[4])/100;          
        newskill->target=atoi(row[5]);
        newskill->atkpower=atoi(row[6]);
        newskill->duration=atoi(row[7]);
        newskill->mp=atoi(row[8]);
        newskill->success=atoi(row[9]); 
        // Buffs get loaded              
        newskill->buff[0]=atoi(row[14]);
        newskill->value1[0]=atoi(row[15]);
        newskill->value2[0]=atoi(row[16]);
        newskill->buff[1]=atoi(row[17]);
        newskill->value1[1]=atoi(row[18]);
        newskill->value2[1]=atoi(row[19]);
        newskill->buff[2]=atoi(row[20]);
        newskill->value1[2]=atoi(row[21]);
        newskill->value2[2]=atoi(row[22]);
        
        
        newskill->clevel=atoi(row[23]);            
        newskill->aoe=atoi(row[24]);
        newskill->aoeradius=atoi(row[25])/100;
        newskill->script=atoi(row[26]);
        newskill->svalue1=atoi(row[27]);
        newskill->nbuffs = 0; 
        if(newskill->buff[0]!=0)
            newskill->nbuffs += 1;
        if(newskill->buff[1]!=0)
            newskill->nbuffs += 2;            
        if(newskill->buff[2]!=0)
            newskill->nbuffs += 4;                        
        char *tmp;
        //weapon list
        if((tmp = strtok( row[10] , "|"))==NULL)
            newskill->weapon[0]=0;
        else
            newskill->weapon[0]=atoi(tmp);            
        for(unsigned int i=1;i<5; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                newskill->weapon[i]=0;            
            else
                newskill->weapon[i]=atoi(tmp);            
        }
        //class list
        if((tmp = strtok( row[11] , "|"))==NULL)
            newskill->c_class[0]=0;
        else
            newskill->c_class[0]=atoi(tmp);            
        for(unsigned int i=1;i<4; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                newskill->c_class[i]=0;            
            else
                newskill->c_class[i]=atoi(tmp);            
        }
        //rskill list
        if((tmp = strtok( row[12] , "|"))==NULL)
            newskill->rskill[0]=0;
        else
            newskill->rskill[0]=atoi(tmp);            
        for(unsigned int i=1;i<3; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                newskill->rskill[i]=0;            
            else
                newskill->rskill[i]=atoi(tmp);            
        }        
        
        //rskill level list
        if((tmp = strtok( row[13] , "|"))==NULL)
            newskill->lskill[0]=0;
        else
            newskill->lskill[0]=atoi(tmp);            
        for(unsigned int i=1;i<3; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                newskill->lskill[i]=0;            
            else
                newskill->lskill[i]=atoi(tmp);            
        }   
        SkillList.push_back( newskill ); 
	}
	DB->QFree( );	    
	return true;	
}

bool CWorldServer::LoadTeleGateData( )
{
	Log( MSG_LOAD, "Telegates data       " );     
	MYSQL_ROW row;    
	MYSQL_RES *result = DB->QStore("SELECT id,x,y,map FROM list_telegates");	
	if(result==NULL) return false;
	while( row = mysql_fetch_row(result) )
    {
		CTeleGate* thisgate = new (nothrow) CTeleGate;
        if(thisgate==NULL)
        {
            Log(MSG_ERROR, "Error allocing memory       " );
            DB->QFree( );
            return false;
        }		
		thisgate->id = atoi(row[0]);
		thisgate->dest.x = (float)atof(row[1]);
		thisgate->dest.y = (float)atof(row[2]);
		thisgate->destMap = atoi(row[3]);
		TeleGateList.push_back( thisgate );
	}
	DB->QFree( );   
	return true;	
}

bool CWorldServer::LoadQuestData( )
{
    Log( MSG_LOAD, "Quest data        " );    
	MYSQL_ROW row;
	MYSQL_RES *result = DB->QStore("SELECT id,questid,mobs,items,itemsreward,exp,zulie,itemid,numitems,finalid,nitems, citems,script,value1,value2,value3,startItems FROM quest_data order by id");
    if(result==NULL) return false;
	while( row = mysql_fetch_row(result) )
    {    
		CQuest* thisquest = new (nothrow) CQuest;
        if(thisquest==NULL)
        {
            Log(MSG_ERROR, "Error allocing memory" );
            DB->QFree( );
            return false;
        }	
        thisquest->id = atoi(row[0]);
        thisquest->questid = atoi(row[1]);
        if( thisquest->questid == 0 )
        {
            delete thisquest;
            continue;
        }                                     
        char *tmp;
        //load quest mobs 
        if((tmp = strtok( row[2] , "|"))==NULL)
            thisquest->mobs[0]=0;
        else
            thisquest->mobs[0]=atoi(tmp);            
        for(int i=1;i<10; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                thisquest->mobs[i]=0;            
            else
                thisquest->mobs[i]=atoi(tmp);            
        }
        //load quest items 
        if((tmp = strtok( row[3] , "|"))==NULL)
            thisquest->items[0]=0;
        else
            thisquest->items[0]=atoi(tmp);            
        for(int i=1;i<10; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                thisquest->items[i]=0;            
            else
                thisquest->items[i]=atoi(tmp);            
        }    
        //load quest start items 
        if((tmp = strtok( row[16] , "|"))==NULL)
            thisquest->startItems[0]=0;
        else
            thisquest->startItems[0]=atoi(tmp);                            
        for(int i=1;i<10; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                thisquest->startItems[i]=0;            
            else
                thisquest->startItems[i]=atoi(tmp);            
        }
        
         //load quests variables
        tmp = strtok( row[16] , "#");
        if((tmp = strtok( NULL , "#"))==NULL)
            thisquest->QVoffset=0;
        else
            thisquest->QVoffset=atoi(tmp);
        if((tmp = strtok( NULL , "#"))==NULL)
            thisquest->QVvalue=0;
        else
            thisquest->QVvalue=atoi(tmp); 
        //load reward items
        if((tmp = strtok( row[4] , "|"))==NULL)
        {
            thisquest->Itemreward[0] = 0;
            thisquest->ItemType[0] = 0;            
        }
        else
        {
            thisquest->Itemreward[0] = atoi(tmp)%1000;    
            thisquest->ItemType[0] = atoi(tmp)/1000;         
        }
        for(int i=1;i<10; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
            {
                thisquest->Itemreward[i]=0;   
                thisquest->ItemType[i]=0;                         
            }
            else
            {
                thisquest->Itemreward[i] = atoi(tmp)%1000;            
                thisquest->ItemType[i] = atoi(tmp)/1000;                         
            }            
        }    
       //Load our items
        if((tmp = strtok( row[7] , "|"))==NULL)
            thisquest->itemid[0]=0;
        else
            thisquest->itemid[0]=atoi(tmp);            
        for(int i=1;i<10; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                thisquest->itemid[i]=0;            
            else
                thisquest->itemid[i]=atoi(tmp);            
        }           
        //Load our items count
        if((tmp = strtok( row[8] , "|"))==NULL)
            thisquest->numitems[0]=0;
        else
            thisquest->numitems[0]=atoi(tmp);            
        for(int i=1;i<10; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                thisquest->numitems[i]=0;            
            else
                thisquest->numitems[i]=atoi(tmp);            
        }   
        //Load our items reward count
        if((tmp = strtok( row[10] , "|"))==NULL)
            thisquest->CountItem[0]=0;
        else
            thisquest->CountItem[0]=atoi(tmp);            
        for(int i=1;i<10; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                thisquest->CountItem[i]=0;            
            else
                thisquest->CountItem[i]=atoi(tmp);            
        }     
        //Load our quest items
        if((tmp = strtok( row[11] , "|"))==NULL)
            thisquest->CItem[0]=0;
        else
            thisquest->CItem[0]=atoi(tmp);            
        for(int i=1;i<5; i++) 
        {
            if((tmp = strtok( NULL , "|"))==NULL)
                thisquest->CItem[i]=0;            
            else
                thisquest->CItem[i]=atoi(tmp);            
        }                                                  
        thisquest->ExpReward = atoi( row[5] );
        thisquest->ZulieReward = atoi( row[6] );  
        thisquest->finalid = atoi( row[9] );   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -