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

📄 worldserver.cpp.svn-base

📁 ROSE的源代码。了解的自己研究,编译通过
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
    	csock = socket( AF_INET, SOCK_STREAM, 0 );
    	if (csock == INVALID_SOCKET)
        {
            Log( MSG_WARNING, "Could not access login server" );
        }
    	struct sockaddr_in ain;
    	ain.sin_family		= AF_INET;
       	ain.sin_addr.s_addr	= inet_addr( Config.CharIP );
    	ain.sin_port = htons( Config.CharPort );
    	if ( connect( csock, (SOCKADDR*) &ain, sizeof(ain) ) == SOCKET_ERROR )
    		Log( MSG_WARNING, "Could not access charserver" );
    	BEGINPACKET( pak, 0x500 );
        ADDDWORD   ( pak, Config.CharPass );
        ADDDWORD   ( pak, Config.ServerID );
        ADDWORD    ( pak, Config.WorldPort );
    	cryptPacket( (char*)&pak, NULL );
    	send( csock, (char*)&pak, pak.Size, 0 );
    }

	float loadtime = (float)( clock() - timer ) / CLOCKS_PER_SEC;
	Log(  MSG_INFO, "Server took %.4f seconds to load", loadtime );

	return true;
}

// Send Levelup To charserver
bool CWorldServer::SendLevelUPtoChar(CPlayer *thisclient)
{        
	BEGINPACKET( pak, 0x79e );
	ADDWORD( pak, thisclient->CharInfo->charid );
	ADDWORD( pak, thisclient->Stats->Level );
	cryptPacket( (char*)&pak, NULL );
	send( csock, (char*)&pak, pak.Size, 0 );   
    return true;
}

// disconect all the clients
void CWorldServer::DisconnectAll()
{    
    for(UINT i=0;i<ClientList.size();i++)
    {
        CPlayer* otherclient = (CPlayer*) ClientList.at(i)->player;
		if(otherclient->Session->isLoggedIn) 
		{            
            otherclient->savedata( );
            otherclient->Saved = true;
            otherclient->client->isActive = false;
        } 
	}       
}

// Load Server configuration
void CWorldServer::LoadConfigurations( char* file )
{
    //Database
	Config.SQLServer.pcServer   = ConfigGetString ( file, "mysql_host", "localhost" );
	Config.SQLServer.pcDatabase = ConfigGetString ( file, "mysql_database", "roseon_beta" );
    Config.SQLServer.pcUserName = ConfigGetString ( file, "mysql_user", "root" );    
	Config.SQLServer.pcPassword = ConfigGetString ( file, "mysql_pass", "" );
	Config.SQLServer.pcPort     = ConfigGetInt    ( file, "mysql_port", 3306 );		
    //Server	
	Config.ServerID             = ConfigGetInt    ( file, "serverid", 1 );    
	Config.ServerType           = ConfigGetInt    ( file, "servertype", 2 );    
	Config.WorldPort            = ConfigGetInt    ( file, "serverport", 29200 );	
	Config.WorldIP              = ConfigGetString ( file, "serverip", "127.0.0.1" ); 	
	Config.ParentID             = ConfigGetInt    ( file, "parentid", 1 );
	Config.ServerName           = ConfigGetString ( file, "servername", "Channel" );
    Config.MaxConnections       = ConfigGetInt    ( file, "maxconnections", 100 );    
    Config.Connection           = ConfigGetInt    ( file, "connection", 0 );        
    Config.LanIP                = ConfigGetString ( file, "lanip", "192.168.0.1" );
    Config.LanSubnet            = ConfigGetString ( file, "lansubmask", "192.168.0" );
    //World
    Config.MinimumAccessLevel   = ConfigGetInt    ( file, "minimal_access_level", 100 );    
	Config.usethreads           = ConfigGetInt    ( file, "usethreads", 0 )==0?false:true;
	Config.EXP_RATE             = ConfigGetInt    ( file, "exp_rate", 10 );
	Config.DROP_RATE            = ConfigGetInt    ( file, "drop_rate", 1 );
    Config.DROP_TYPE            = ConfigGetInt    ( file, "drop_type", 2 );  	
	Config.ZULY_RATE            = ConfigGetInt    ( file, "zuly_rate", 1 );
	Config.WELCOME_MSG          = ConfigGetString ( file, "welcome_msg", "Welcome to Rose Online" );
    Config.AUTOSAVE             = ConfigGetInt    ( file, "autosave", 0 );	
	Config.SAVETIME             = ConfigGetInt    ( file, "savetime", 3600 );	    
    Config.MapDelay             = ConfigGetInt    ( file, "mapdelay", 10 );  
    Config.WorldDelay           = ConfigGetInt    ( file, "worlddelay", 200 );  
    Config.VisualDelay          = ConfigGetInt    ( file, "visualdelay", 500 );
    Config.Partygap             = ConfigGetInt    ( file, "partygap", 10 ); 
    Config.MaxStat              = ConfigGetInt    ( file, "maxstat", 254 ); 
    Config.FairyMode            = ConfigGetInt    ( file, "fairy", 1 );
    Config.FairyStay            = ConfigGetInt    ( file, "fairystay", 20 ); 
    Config.FairyWait            = ConfigGetInt    ( file, "fairywait", 15 );  
    Config.FairyMax             = ConfigGetInt    ( file, "fairymax", 0); 
    Config.FairyTestMode        = ConfigGetInt    ( file, "fairytestmode", 1);
    Config.PlayerDmg            = ConfigGetInt    ( file, "playerdmg", 120);                 
    Config.MonsterDmg           = ConfigGetInt    ( file, "monsterdmg", 100);
    Config.Cfmode               = ConfigGetInt    ( file, "cfmode", 0);
    Config.osRoseVer             = ConfigGetInt    ( file, "osRoseVer", 79);
    
    Log (MSG_INFO, "osRose Revision %i", Config.osRoseVer );
        
    //Password
	Config.LoginPass            = ConfigGetInt    ( file, "loginpass", 123456 );		
	Config.CharPass             = ConfigGetInt    ( file, "charpass", 123456 );	
	Config.WorldPass            = ConfigGetInt    ( file, "worldpass", 123456 );
    if(Config.AUTOSAVE==1)
        Log( MSG_INFO, "Autosaving Every %i minutes", Config.SAVETIME/60 );	

    LoadCommandLevels();    
}

// Load commands from commands.ini [by Paul_T]
void CWorldServer::LoadCommandLevels( void )
{
    Config.Command_Ani = ConfigGetInt    ( "commands.ini", "ani", 299 );
    Config.Command_Ann = ConfigGetInt    ( "commands.ini", "ann", 299 );
    Config.Command_Ban = ConfigGetInt    ( "commands.ini", "ban", 299 );
    Config.Command_Cha = ConfigGetInt    ( "commands.ini", "cha", 299 );
    Config.Command_ChangeFairyWait = ConfigGetInt    ( "commands.ini", "changefairywait", 299 );
    Config.Command_ChangeFairyStay = ConfigGetInt    ( "commands.ini", "changefairystay", 299 );
    Config.Command_ChangeFairyTestMode = ConfigGetInt    ( "commands.ini", "changefairytestmode", 299 );
    Config.Command_Class = ConfigGetInt    ( "commands.ini", "class", 299 );
    Config.Command_Convert = ConfigGetInt    ( "commands.ini", "convert", 299 );
    Config.Command_Cfmode = ConfigGetInt    ( "commands.ini", "cfmode", 299 ); 
    Config.Command_DelSpawn = ConfigGetInt    ( "commands.ini", "delspawn", 299 );
    Config.Command_DQuest = ConfigGetInt    ( "commands.ini", "dquest", 299 );
    Config.Command_Drop = ConfigGetInt    ( "commands.ini", "drop", 299 );
    Config.Command_DSpawn = ConfigGetInt    ( "commands.ini", "dspawn", 299 );
    Config.Command_ESpawn = ConfigGetInt    ( "commands.ini", "espawn", 299 );
    Config.Command_Exp = ConfigGetInt    ( "commands.ini", "exp", 299 );
    Config.Command_Face = ConfigGetInt    ( "commands.ini", "face", 299 );
    Config.Command_Give2 = ConfigGetInt    ( "commands.ini", "give2", 299 );
    Config.Command_GiveFairy = ConfigGetInt    ( "commands.ini", "givefairy", 299 );
    Config.Command_GiveZuly = ConfigGetInt    ( "commands.ini", "givezuly", 299 );
    Config.Command_Go = ConfigGetInt    ( "commands.ini", "go", 299 );
    Config.Command_Goto = ConfigGetInt    ( "commands.ini", "goto", 299 );
    Config.Command_GoToMap = ConfigGetInt    ( "commands.ini", "gotomap", 299 );
    Config.Command_Hair = ConfigGetInt    ( "commands.ini", "hair", 299 );
    Config.Command_Heal = ConfigGetInt    ( "commands.ini", "heal", 299 );
    Config.Command_Here = ConfigGetInt    ( "commands.ini", "here", 299 );
    Config.Command_Hide = ConfigGetInt    ( "commands.ini", "hide", 299 );
    Config.Command_Info = ConfigGetInt    ( "commands.ini", "info", 299 );
    Config.Command_IQuest = ConfigGetInt    ( "commands.ini", "iquest", 299 );
    Config.Command_Item = ConfigGetInt    ( "commands.ini", "item", 299 );
    Config.Command_Job = ConfigGetInt    ( "commands.ini", "job", 299 );
    Config.Command_Kick = ConfigGetInt    ( "commands.ini", "kick", 299 );
    Config.Command_KillInRange = ConfigGetInt    ( "commands.ini", "killinrange", 299 );
    Config.Command_Level = ConfigGetInt    ( "commands.ini", "level", 299 );
    Config.Command_LevelUp = ConfigGetInt    ( "commands.ini", "levelup", 299 );
    Config.Command_ManageFairy = ConfigGetInt    ( "commands.ini", "managefairy", 299 );
    Config.Command_Mdmg = ConfigGetInt    ( "commands.ini", "mdmg", 299 );
    Config.Command_Mon = ConfigGetInt    ( "commands.ini", "mon", 299 );
    Config.Command_Mon2 = ConfigGetInt    ( "commands.ini", "mon2", 299 );
    Config.Command_Monster    = ConfigGetInt    ( "commands.ini", "monster", 299 );
    Config.Command_Move = ConfigGetInt    ( "commands.ini", "move", 299 );
    Config.Command_Moveto = ConfigGetInt    ( "commands.ini", "moveto", 299 );
    Config.Command_Mute = ConfigGetInt    ( "commands.ini", "mute", 299 );
    Config.Command_Event = ConfigGetInt    ( "commands.ini", "event", 299 );     //Event
    Config.Command_Npc = ConfigGetInt    ( "commands.ini", "npc", 299 );
    Config.Command_Pak = ConfigGetInt    ( "commands.ini", "pak", 299 );
    Config.Command_Pak2 = ConfigGetInt    ( "commands.ini", "pak2", 299 );
    Config.Command_Pakm = ConfigGetInt    ( "commands.ini", "pakm", 299 );
    Config.Command_Partylvl = ConfigGetInt      ( "commands.ini", "partylvl", 299);
    Config.Command_PlayerInfo = ConfigGetInt    ( "commands.ini", "playerinfo", 299 );
    Config.Command_Pdmg = ConfigGetInt    ( "commands.ini", "pdmg", 299 );
    Config.Command_Pvp = ConfigGetInt    ( "commands.ini", "pvp", 299 );
    Config.Command_Rate = ConfigGetInt    ( "commands.ini", "rate", 299 );
    Config.Command_Reborn = ConfigGetInt    ( "commands.ini", "reborn", 299 );  //Reborn by core
    Config.Command_Reload = ConfigGetInt    ( "commands.ini", "reload", 299 );
    Config.Command_ReloadQuest = ConfigGetInt    ( "commands.ini", "reloadquest", 299 );
    Config.Command_Rules = ConfigGetInt    ( "commands.ini", "rules", 99 );
    Config.Command_Save = ConfigGetInt    ( "commands.ini", "save", 299 );
    Config.Command_ServerInfo = ConfigGetInt    ( "commands.ini", "serverinfo", 299 );
    Config.Command_Set = ConfigGetInt    ( "commands.ini", "set", 299 );
    Config.Command_Settime = ConfigGetInt    ( "commands.ini", "settime", 299 );
    Config.Command_ShopType = ConfigGetInt    ( "commands.ini", "shoptype", 299 );
    Config.Command_Shutdown = ConfigGetInt    ( "commands.ini", "shutdown", 299 );
    Config.Command_SSpawn = ConfigGetInt    ( "commands.ini", "sspawn", 299 );
    Config.Command_Stat = ConfigGetInt    ( "commands.ini", "stat", 299 );
    Config.Command_Summon = ConfigGetInt    ( "commands.ini", "summon", 299 );
    Config.Command_TargetInfo = ConfigGetInt    ( "commands.ini", "targetinfo", 299 );
    Config.Command_Tele = ConfigGetInt    ( "commands.ini", "tele", 299 );
    Config.Command_TeleToMe = ConfigGetInt    ( "commands.ini", "teletome", 299 );
    Config.Command_Transx = ConfigGetInt    ( "commands.ini", "transx", 299 );
    Config.Command_Who = ConfigGetInt    ( "commands.ini", "who", 299 );
    Config.Command_Who2 = ConfigGetInt    ( "commands.ini", "who2", 299 );
    Config.Command_Broadcast = ConfigGetInt    ( "commands.ini", "broadcast", 299 );
    Config.Command_GlobalTime  = ConfigGetInt    ( "commands.ini", "globaldelay", 30 );
    Config.Command_GlobalPrefix = ConfigGetString    ( "commands.ini", "globalprefix", "[Broadcast]" );

}
// Incoming packet
bool CWorldServer::OnReceivePacket( CClientSocket* thisclient, CPacket *P )
{
	switch( P->Command )
	{
        case 0x0500: return pakCSReady          ( (CPlayer*)thisclient->player, P );
        case 0x0502: return pakCharDSClient     ( (CPlayer*)thisclient->player, P );        
    	case 0x0505: return pakCSCharSelect     ( (CPlayer*)thisclient->player, P );
    	case 0x0756: return true;//unknown
    	case 0x0700: return pakPing             ( (CPlayer*)thisclient->player, P );
    	case 0x0707: return pakExit             ( (CPlayer*)thisclient->player, P );
    	case 0x070b: return pakDoIdentify       ( (CPlayer*)thisclient->player, P );
    	case 0x071c: return pakCharSelect       ( (CPlayer*)thisclient->player, P );
    	case 0x0730: return pakGiveQuest        ( (CPlayer*)thisclient->player, P );
    	case 0x0753: return pakDoID             ( (CPlayer*)thisclient->player, P );
    	case 0x0755: return pakUserDied         ( (CPlayer*)thisclient->player, P );
    	case 0x0762: return pakWeight           ( (CPlayer*)thisclient->player, P );
    	case 0x0771: return pakStopChar         ( (CPlayer*)thisclient->player, P );
    	case 0x0781: return pakDoEmote          ( (CPlayer*)thisclient->player, P );
    	case 0x0782: return pakChangeStance     ( (CPlayer*)thisclient->player, P );
    	case 0x0783: return pakNormalChat       ( (CPlayer*)thisclient->player, P );
    	case 0x0784: return pakWhisper          ( (CPlayer*)thisclient->player, P );
    	case 0x0785: return pakShout            ( (CPlayer*)thisclient->player, P );
    	case 0x0786: return pakPartyChat        ( (CPlayer*)thisclient->player, P );
    	case 0x0798: return pakStartAttack      ( (CPlayer*)thisclient->player, P );
      	case 0x079f: return pakShowHeal         ( (CPlayer*)thisclient->player, P );
    	case 0x079a: return pakMoveChar         ( (CPlayer*)thisclient->player, P );
    	case 0x07a1: return pakNPCBuy           ( (CPlayer*)thisclient->player, P );
        case 0x07a3: return pakUseItem          ( (CPlayer*)thisclient->player, P );
        case 0x07a4: return pakDoDrop           ( (CPlayer*)thisclient->player, P );
    	case 0x07a5: return pakChangeEquip      ( (CPlayer*)thisclient->player, P );
    	case 0x07a7: return pakPickDrop         ( (CPlayer*)thisclient->player, P );
    	case 0x07a8: return pakGate             ( (CPlayer*)thisclient->player, P );
    	case 0x07a9: return pakAddStats         ( (CPlayer*)thisclient->player, P );
    	case 0x07aa: return pakMoveSkill        ( (CPlayer*)thisclient->player, P );
    	case 0x07ab: return pakEquipABC         ( (CPlayer*)thisclient->player, P );
    	case 0x07af: return pakCraft            ( (CPlayer*)thisclient->player, P );	    	
        case 0x07b1: return pakLevelUpSkill     ( (CPlayer*)thisclient->player, P );
        case 0x07b2: return pakSkillSelf        ( (CPlayer*)thisclient->player, P );	
    	case 0x07b3: return pakStartSkill       ( (CPlayer*)thisclient->player, P );
    	case 0x07b4: return pakSkillAOE         ( (CPlayer*)thisclient->player, P );            	        
    	case 0x07c0: return pakTradeAction      ( (CPlayer*)thisclient->player, P );
    	case 0x07c1: return pakTradeAdd         ( (CPlayer*)thisclient->player, P );
    	case 0x07ad: return pakStorage          ( (CPlayer*)thisclient->player, P );
    	case 0x07ae: return pakChangeStorage    ( (CPlayer*)thisclient->player, P );
    	case 0x07ba: return pakidentify         ( (CPlayer*)thisclient->player, P );
    	case 0x07bc: return pakModifiedItem     ( (CPlayer*)thisclient->player, P );
    	case 0x07bf: return true;//add to wishlist
    	case 0x07c2: return pakOpenShop         ( (CPlayer*)thisclient->player, P );    	    	
    	case 0x07c3: return pakCloseShop        ( (CPlayer*)thisclient->player, P );    	    	    	
        case 0x07c4: return pakShowShop         ( (CPlayer*)thisclient->player, P );    	    	    	 	
        case 0x07c5: return pakBuyShop          ( (CPlayer*)thisclient->player, P );
        case 0x07c6: return pakSellShop         ( (CPlayer*)thisclient->player, P );        
    	case 0x07ca: return pakChangeCart       ( (CPlayer*)thisclient->player, P );
    	//case 0x07cb: return pakRepairItem       ( (CPlayer*)thisclient->player, P );
    	case 0x07cb: case 0x07cd: Log( MSG_WARNING, "(SID:%i) Received packet. Command:%04x Size:%04x", thisclient->sock, P->Command, P->Size ); return pakRepairItem       ( (CPlayer*)thisclient->player, P );    	
    	case 0x07d0: return pakPartyActions     ( (CPlayer*)thisclient->player, P );
    	case 0x07d1: return pakPartyManager     ( (CPlayer*)thisclient->player, P );    	
    	case 0x07d7: return pakPartyOption      ( (CPlayer*)thisclient->player, P );    	
    	case 0x07d8: return pakModifiedItemDone ( (CPlayer*)thisclient->player, P );    	
        case 0x07d9: return pakItemMall         ( (CPlayer*)thisclient->player, P );    	
    	case 0x07da: return pakStoreZuly        ( (CPlayer*)thisclient->player, P );
    	case 0x07dd: return pakRideRequest      ( (CPlayer*)thisclient->player, P );
    	case 0x07e0: return pakCreateClan       ( (CPlayer*)thisclient->player, P );
    	case 0x07e1: return pakClanManager      ( (CPlayer*)thisclient->player, P );
    	case 0x07eb: return pakPrintscreen      ( (CPlayer*)thisclient->player, P ); 
    	case 0x0808: return pakGameGuard        ( (CPlayer*)thisclient->player, P );
    	default:
    		Log( MSG_WARNING, "(SID:%i) Received unknown packet. Command:%04x Size:%04x", thisclient->sock, P->Command, P->Size );
		break;
	}
	return true;
}

⌨️ 快捷键说明

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