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

📄 dragonserver.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			tp.u.gs_req_insert_userid.server_id = cn;
			strcpy(tp.u.gs_req_insert_userid.id, pAJ->id);
			strcpy(tp.u.gs_req_insert_userid.pw, pAJ->pw);
			strcpy(tp.u.gs_req_insert_userid.name, pAJ->name);
			strcpy(tp.u.gs_req_insert_userid.mapname, MapName);
			QueuePacket(connections, DB_DEMON, &tp, 1);
			break;
		}	//> CSD-HK-030829
	case CMD_JOINABLE: // DB_DEMON 俊辑 罐酒档 亮促绰 倾遏阑 罐疽促. 
		{	//< CSD-HK-030829
			const int server_id = packet->u.ls_joinable.server_id;

			if (connections[server_id].dwAgentConnectionIndex == 0)
			{
				break;
			}
			
			if (connections[server_id].state != CONNECT_LOGIN && connections[server_id].state != CONNECT_LOGIN_KEIN)
			{
				break;
			}
			//> CSD-HK-030829
			packet->h.header.type = CMD_ASSIGN_SERVER_ID;
			packet->h.header.size = sizeof(t_server_assign_server_id );
			packet->u.server_assign_server_id.server_id	= server_id;
			connections[server_id].chrlst.SetServerID(server_id);
			QueuePacket(connections, server_id, packet, 1);
			// DB率俊 倾遏罐篮 某腐俊 措茄 Data甫 夸没茄促. 
			// 弥檬俊 甘俊 甸绢棵版快, 甘捞悼捞 酒匆版快...
			if( connections[server_id].state == CONNECT_LOGIN )			
			{	
				packet->h.header.type = CMD_ACCESS_CHAR_DB;
				packet->u.server_access_char_db.server_id	= server_id;
				memcpy(packet->u.server_access_char_db.id,	connections[server_id].id,	ID_LENGTH);
				memcpy(packet->u.server_access_char_db.name, connections[server_id].name,	NM_LENGTH);
				packet->h.header.size = sizeof(t_server_access_char_db);
				::QueuePacket(connections, DB_DEMON, packet, 1);
				
				t_packet	GuildPacket;//瘤虐固 辨靛府胶飘 焊晨.
				GuildPacket.h.header.type = CMD_GUARDIANLIST;
				GuildPacket.h.header.size = sizeof(t_GUARDIANLIST);
				const int count = GuildPacket.u.GuardianList.nCount = g_CGuardianGuild.GetCount();
				for(int i = 0;i < count;++i)
				{
					GuildPacket.u.GuardianList.anGuildCodes[i] = g_CGuardianGuild.GetGuildCode(i);	
				}
				::QueuePacket( connections, server_id, &GuildPacket, 1 );
				
				::SendReqGetCharInfoEtc( server_id, connections[server_id].name );	// 0410 YGI	// 某腐磐 眠啊 沥焊甫 罐酒 柯促.
				connections[server_id].chrlst.updatable = 0;			// 030919 HK YGI
			}

			break;
		}
	case CMD_NOT_JOINABLE:
		{	//< CSD-HK-030828
			const int server_id = packet->u.ls_not_joinable.server_id;
			
			if (connections[server_id].dwAgentConnectionIndex == 0)
			{
				break;
			}
			
			if (connections[server_id].state != CONNECT_LOGIN)
			{
				break;
			}
			
			packet->h.header.type = CMD_INVALID_ID;
			packet->h.header.size = 0;
			QueuePacket( connections, server_id, packet, 1 );
			break;
		}	//> CSD-HK-030828
	case CMD_ACCEPT_CHAR_DB:
		{
			t_server_accept_char_db  *tt = &packet->u.server_accept_char_db;
			const int server_id = tt->server_id;
			if( !CheckServerIndex( server_id ) ) 
			{
				MyLog( 0, "CMD_ACCEPT_CHAR_DB, wrong server_id : [%d]", server_id );	// 030923 HK YGI
				break;
			}
			LPCHARLIST ch = &connections[server_id].chrlst;
			// 030923 HK YGI
			if( strcmp( tt->name, connections[server_id].name ) != 0 ) 
			{
				MyLog( 0, "CMD_ACCEPT_CHAR_DB, wrong character name : [%s], [%s]", tt->name, connections[server_id].name );
				break; // 030921 HK YGI
			}
			
			strcpy( ch->Name, connections[server_id].name );		// KHS
			EatRearWhiteChar( ch->Name );
			
			ch->SetLevel(tt->Level); // CSD-030806
			ch->Exp			= tt->Exp;
			
			ch->Gender		= tt->Gender;
			ch->Face		= tt->Face;
			ch->SetGuildCode(tt->nGuildCode); // CSD-030806
			ch->Class		= tt->Class;
			ch->Job			= tt->Job;
			ch->Spell		= tt->Spell;
			
			ch->Str  		= tt->Str;
			ch->Con  		= tt->Con;
			ch->Dex  		= tt->Dex;
			ch->Wis  		= tt->Wis;
			ch->Int  		= tt->Int;
			ch->MoveP		= tt->MoveP;
			ch->Char 		= tt->Char;
			ch->Endu 		= tt->Endu;
			ch->Moral 		= tt->Moral;
			
			ch->Money		= tt->Money;
			ch->Hp = tt->nLife;
			ch->HpMax = tt->nMaxHp;
			
			ch->Mana = tt->nMana;//020214 lsw
			ch->ManaMax	= tt->nMaxMp;
			ch->Hungry = tt->nHungry;
			ch->HungryMax = tt->nMaxHungry;
			
			ch->SetState(tt->Condition);
			ch->SprNo		= tt->SprNo;
			ch->X    		= tt->X;
			ch->Y    		= tt->Y;
			
			memcpy( ch->MapName, MapName, 20);
			
			ch->Peacests	= tt->Peacests;
			ch->Sight		= tt->Sight;
			
			ch->BodyR		= tt->BodyR;
			ch->BodyG		= tt->BodyG;
			ch->BodyB		= tt->BodyB;
			
			ch->ClothR		= tt->ClothR;
			ch->ClothG		= tt->ClothG;
			ch->ClothB		= tt->ClothB;
			
			ch->Age			= tt->Age;
			ch->Luck		= tt->Luck;		// 0208 YGI
			ch->wsps		= tt->wsps;
			memcpy( &ch->name_status, &tt->nation, sizeof(DWORD ) );		// 1004 YGI
			
			ch->accessory[0] = tt->accessory[0];
			ch->accessory[1] = tt->accessory[1];
			ch->accessory[2] = tt->accessory[2];
			ch->accessory[3] = tt->accessory[3];
			ch->mantle		 = tt->mantle;// 011018 KHS 噶肚 
			
			ch->openhouse	= tt->openhouse;
			ch->total_id	= tt->total_id;
			ch->viewtype	 = tt->viewtype;
			
			ch->SetBasicResist(RT_POISON,tt->nPoison); // 历林拌凯 付过俊 措茄 历亲仿//030227 lsw
			ch->SetBasicResist(RT_CURSE,tt->nCurse); //	历林拌凯 付过俊 措茄 历亲仿
			ch->SetBasicResist(RT_HOLY,tt->nHoly); // 脚仿拌凯 傍拜 付过俊 措茄 历亲仿
			ch->SetBasicResist(RT_FIRE,tt->nFire); //	阂拌凯 傍拜 付过俊 措茄 历亲仿
			ch->SetBasicResist(RT_ICE,tt->nIce); //	倔澜拌凯 傍拜 付过俊 措茄 历亲仿
			ch->SetBasicResist(RT_ELECT,tt->nElect); //	傈拜拌凯 傍拜 付过俊 措茄 历亲仿
			
			ch->social_status	= tt->social_status;
			ch->fame			= tt->fame;
			ch->fame_pk			= tt->fame_pk;	// 010915 LTS	//Fame_PK -> NWCharacter肺 背眉 DB俊绰 角力肺 NWCharacter狼 蔼捞 甸绢癌聪促.		
			ch->NWCharacter		= tt->NWCharacter;	// 010915 LTS
			// 磊悼 Update窍扁 困茄 扁夯 Data Setting.
			ch->timetoupdate	= g_curr_time;
			ch->SetStepInfo(tt->aStepInfo, sizeof(tt->aStepInfo));

			ch->m_nUserAge		= tt->nUserAge;			// 030929 kyo
			ch->EventJoin		= tt->EventJoin;		// 020115 LTS
			// 030923 HK YGI
			extern void SaveLoginLogoutLogByKein( CHARLIST *ch, int type, int );
			SaveLoginLogoutLogByKein( ch, 1, 0 );

			break;
		}
	case CMD_ACCEPT_CHAR_GAME_DB:
		{
			int px, py;
			t_server_accept_char_game_db *tt = &packet->u.server_accept_char_game_db;
			const int server_id	= tt->server_id;
			// 030921 HK YGI
			if( !CheckServerIndex( server_id ) )break;
			if( strcmp( tt->name, connections[server_id].name ) != 0 ) break; 
			
			LPCHARLIST ch = &connections[server_id].chrlst;
			ch->SetBankMoney(tt->BankMoney, BMCT_CHAR_LOGIN); // CSD-030723
			
			memcpy( &ch->WinLoseScore, &tt->win_defeat, sizeof( DWORD ) );
			ch->LadderScore = tt->LadderScore;
			ch->LastLoan 	= tt->LastLoan;
			
			ch->nk[ N_VYSEUS]	= tt->nk3;
			ch->nk[ N_ZYPERN]	= tt->nk4;
			ch->nk[ N_YILSE] 	= tt->nk6;
			
			ch->killmon		= tt->killmon;
			ch->killanimal	= tt->killanimal;
			ch->killpc 		= tt->killpc;
			ch->SetReservedPoint(tt->reserved_point);
			ch->Tactics		= tt->Tactics;
			// 霸烙俊 甸绢客 辑 扁夯利栏肺  Setting秦具 且巴...
			ch->itemweight		= GetTotalItemWeight( ch );
			
			if( ch->Peacests < 0 || ch->Peacests > 1 ) ch->Peacests = 0;
			
			if( ch->startposition == 99 )
			{	
				px = ch->X>>5;
				py = ch->Y>>5;
				NPC_AdjustPosition( ch->SprNo, &px, &py );
				
				ch->X = px * TILE_SIZE + 16;
				ch->Y = py * TILE_SIZE + 16;
			}	
			else 
			{	
				px = ch->X>>5;
				py = ch->Y>>5;
				// 010414 KHS
				// 角力利牢 某腐磐狼 谅钎啊 官差绰镑.  --> 父距, 甘阑 急琶窍咯 
				// DB Demon俊辑 逞绢坷绰 某腐磐狼 谅钎绰 DB狼 郴侩捞绊
				// 捞镑俊辑绰 Client俊辑 急琶茄 Map狼 矫累谅钎肺 Setting茄促. 
				// Recent甫 急琶沁阑 版快俊绰 DB俊辑 焊郴柯 谅钎甫 焊郴霖促.
				// ( 肚绰 DB_Demon:CheckStartMap()俊 狼秦 MapName捞 官拆荐 乐促.. )
				
				if( strcmp( MAPNAME, "MA-IN" ) == 0 )
				{
					switch( rand()%3 )
					{
					case 0 :  px = 247,py = 107; break;
					case 1 :  px = 232,py =  97; break;
					default : px = 266,py = 122; break;
					}
				}
				else if( strcmp( MAPNAME, "RENES_C" ) == 0 ) 
				{
					px = 210, py = 175;
				}
				else if( strcmp( MAPNAME, "COLOR" ) == 0 ) 
				{
					px = 196, py = 156;
				}
				else if( strcmp( MAPNAME, "KAL_OS" ) == 0 ) 
				{
					px = 122, py = 164;
				}
				else if( strcmp( MAPNAME, "SCHOLIUM" ) == 0 ) 
				{
					switch( rand()%2 )
					{
					case 0 :	px = 4;	py = 23; break;
					default :	px = 4;	py = 24; break;
					}
				}
				else if( strcmp( MAPNAME, "BIS_I" ) == 0 )
				{
					switch( rand()%3 )
					{
					case 0 :	px = 253;	py = 449; break;
					case 1 :	px = 292;	py = 456; break;
					default :	px = 274;	py = 472; break;
					}
					
				}
				else if( strcmp( MAPNAME, "IRAMUS" ) == 0 )
				{
					switch( rand()%2 )
					{
					case 0 :	px = 92;	py = 67; break;
					default :	px = 135;	py = 74; break;
					}
				}
				else if( strcmp( MAPNAME, "DEP" ) == 0 )
				{
					switch( rand()%3 )
					{
					case 0 :	px = 276;	py = 360; break;
					case 1 :	px = 289;	py = 369; break;
					default :	px = 302;	py = 381; break;
					}
				}
				else if( strcmp( MAPNAME, "TYNEN" ) == 0 )
				{
					switch( rand()%2 )
					{
					case 0 :	px = 445;	py = 260; break;
					default :	px = 494;	py = 305; break;
					}
				}
				else if( strcmp( MAPNAME, "BARANTAN" ) == 0 )
				{
					switch( rand()%2 )
					{
					case 0 :	px = 329;	py =  95; break;
					default :	px = 360;	py = 150; break;
					}
				}
				else if( strcmp( MAPNAME, "ICE-W01" ) == 0 )
				{
					px = 112, py = 147;
				}
				else if( strcmp( MAPNAME, "K_SUNG2" ) == 0 )
				{
					px = 322, py = 202;
				}
				else if( strcmp( MAPNAME, "SUNG_TILE_00" ) == 0 ) 
				{
					px = 138, py = 215;
				}
				else if( strcmp( MAPNAME, "SOURCE" ) == 0 ) 
				{
					px = 274+ rand()%10, py = 250 + rand()%6;
				}
				else if( strcmp( MAPNAME, "MANDUN1" ) == 0 ) 
				{
					switch( rand()%2 )
					{
					case 0 :	px = 108;	py = 236; break;
					default :	px = 131;	py = 229; break;
					}
				}
				else if( strcmp( MAPNAME, "FIREDUN1" ) == 0 ) 
				{
					px = 128, py = 81;
				}
				else if( strcmp( MAPNAME, "GRAY" ) == 0 ) 
				{
					px = 320, py = 325;
				}
				else if( strcmp( MAPNAME, "SCHOLIUM2" ) == 0 ) //020822 lsw
				{
					switch( rand()%2 )
					{
					case 0 :	px = 124;	py = 74; break;
					default :	px = 132;	py = 62; break;
					}
				}
				
				NPC_AdjustPosition( ch->SprNo, &px, &py );
				
				ch->X = px * TILE_SIZE + 16;
				ch->Y = py * TILE_SIZE + 16;
			}
			
			ch->OldMoveSx = ch->MoveSx = px;
			ch->OldMoveSy = ch->MoveSy = py;
			
			::SetTileOccupied(ch->MoveSx,ch->MoveSy,true);
			
			sRECALL_SCRP_NO = 0; // 捞亥飘啊 惯积窍搁 捞蔼篮 0捞 酒囱蔼栏肺 等促.  甸绢坷搁 促矫 Setting..
			break;
		}	
		case CMD_ACCEPT_BINARY_DATA_ERROR:
			{	//< CSD-030415
				const int idUser = g_pUserManager->GetServerID(packet->u.server_accept_data_error.name);
				
				if (idUser != -1)
				{
					packet->h.header.type = CMD_INVALID_DB;
					packet->h.header.size = sizeof(t_server_accept_data_error);
					QueuePacket(connections, idUser, packet, 1);
				}
				
				break;
			}	//> CSD-030415
		case CMD_ACCEPT_BINARY_DATA:
			{
				const int server_id	= packet->u.server_accept_binary_data.server_id;
				if (!CheckServerIndex(server_id)) break;
				if( strcmp( packet->u.server_accept_binary_data.name, connections[server_id].name ) != 0 ) break; // 030921 HK YGI
				
				memcpy((UCHAR *)connections[server_id].chrlst.Ws,				(UCHAR *)packet->u.server_accept_binary_data.Ws,			SIZE_OF_WS);
				memcpy((UCHAR *)connections[server_id].chrlst.Ps,				(UCHAR *)packet->u.server_accept_binary_data.Ps,			SIZE_OF_PS);
				memcpy((UCHAR *)connections[server_id].chrlst.Skill,			(UCHAR *)packet->u.server_accept_binary_data.Skill,			SIZE_OF_SKILL);
				memcpy((UCHAR *)connections[server_id].chrlst.skillexp,			(UCHAR *)packet->u.server_accept_binary_data.skillexp,		SIZE_OF_SKILL_EXP);
				memcpy((UCHAR *)connections[server_id].chrlst.tac_skillEXP,		(UCHAR *)packet->u.server_accept_binary_data.tac_skillEXP,	SIZE_OF_TAC_SKILL_EXP);
				memcpy((UCHAR *)connections[server_id].chrlst.equip,			(UCHAR *)packet->u.server_accept_binary_data.equip,			SIZE_OF_EQUIP);
				memcpy((UCHAR *)connections[server_id].chrlst.quick,			(UCHAR *)packet->u.server_accept_binary_data.quick,			SIZE_OF_QUICK);
				memcpy((UCHAR *)connections[server_id].chrlst.party_str,		(UCHAR *)packet->u.server_accept_binary_data.party,			SIZE_OF_PARTY);				// 0218 YGI
				memcpy((UCHAR *)connections[server_id].chrlst.relation_str,		(UCHAR *)packet->u.server_accept_binary_data.relation,		SIZE_OF_RELATION);
				memcpy((UCHAR *)connections[server_id].chrlst.employment_str,	(UCHAR *)packet->u.server_accept_binary_data.employment,	SIZE_OF_EMPLOYMENT);
				
				SetTacSkillLevel( &connections[server_id].chrlst );		// 0711 YGI
				SetMySkill( &connections[server_id].chrlst );		// 老窜 扁夯利栏肺 舅酒具窍绰 胶懦 悸
				break;
			}
		case CMD_ACCEPT_SCRIPT_DATA:
			{
				const int server_id	= packet->u.server_accept_script_data.server_id;
				if (!CheckServerIndex(server_id)) break;
				if( strcmp( packet->u.server_accept_script_data.name, connections[server_id].name ) != 0 ) break; // 030921 HK YGI

				memcpy((UCHAR *)var[server_id], (UCHAR *)packet->u.server_accept_script_data.script_var, SIZE_OF_SCRIPT_VAR);
				break;
			}
		case CMD_ACCEPT_INV_DATA:
			{
				const int server_id = packet->u.server_accept_inv_data.server_id;
				if (!CheckServerIndex(server_id)) break;
				if( strcmp( packet->u.server_accept_inv_data.name, connections[server_id].name ) != 0 ) break; // 030921 HK YGI
				
				memcpy((UCHAR *)connections[server_id].chrlst.inv, (UCHAR *)packet->u.server_accept_inv_data.inv, SIZE_OF_INV);
				
				if( packet->u.server_accept_inv_data.refresh_inventory ) 
				{	// 努扼捞攫飘肺 促矫 蔼阑 焊郴林磊...
					RecvResendItem( server_id );
				}

				break;
			}
		case CMD_ACCEPT_ITEM_DATA:
			{
				const int server_id = packet->u.server_accept_item_data.server_id;
				if (!CheckServerIndex(server_id)) break;
				if( strcmp( packet->u.server_accept_item_data.name, connections[server_id].name ) != 0 ) break; // 030921 HK YGI

				memcpy((UCHAR *)connections[server_id].chrlst.Item, (UCHAR *)packet->u.server_accept_item_data.Item, SIZE_OF_ITEMINDEX);
				break;
			}
		case CMD_ACCEPT_BANKITEM_DATA :
			{
				const int server_id	= packet->u.server_accept_bankitem_data.server_id;
				if (!CheckServerIndex(server_id)) break;
				if( strcmp( packet->u.server_accept_bankitem_data.name, connections[server_id].name ) != 0 ) break; // 030921 HK YGI

				memcpy((UCHAR *)connections[server_id].chrlst.bank, (UCHAR *)packet->u.server_accept_bankitem_data.bankitem, SIZE_OF_BANKITEM);
				CheckItem(server_id);		// 0218 YGI//020228 lsw
				
				for( int i = 0 ; i < 1000 ; i ++)
				{
					if (connections[server_id].chrlst.Item[i] == 0)
					{
						break;
					}
				}

				connections[server_id].chrlst.ItemMax = i;
				// 甘俊 甸绢坷绰 谅钎甫 焊郴霖促..
				packet->h.header.type = CMD_ACCEPT_JOIN;
				packet->u.server_accept_join.x = connections[server_id].chrlst.X;
				packet->u.server_accept_join.y = connections[server_id].chrlst.Y;
				packet->h.header.size = sizeof( t_server_accept_join );
				QueuePacket(connections, server_id, packet, 1);
				CheckCharacterWhenJoinGame( &connections[server_id].chrlst );		// 某腐磐俊 贸澜 炼牢 沁阑锭狼 眉农且巴甸
				break;
			}
		case CMD_ALL_READY:
			{	//< CSD-HK-030829 : 捞镑篮 CMD_CHANGE_MAP 促矫 甸绢 坷绰 何盒.
				if (connections[cn].state == CONNECT_JOIN)
				{
					break;
				}
				
				LPCHARLIST ch = &connections[cn].chrlst;
				CheckCurrStats(ch);
				ResetAbility(ch);
				
				ch->MoveGox = ch->X	= packet->u.all_ready.x;
				ch->MoveGoy = ch->Y	= packet->u.all_ready.y;
				ch->MoveSx = ch->X/TILE_SIZE;
				ch->MoveSy = ch->Y/TILE_SIZE;
				ch->attackedblock = 9;
				
				for (int i = 0 ; i < MAX_PC_CONTROL_NPC; ++i)
				{
					ch->ctrlnpc[i] = -1;
				}

				switch (connections[cn].state)
				{
				case CONNECT_LOGIN:
				case CONNECT_LOGIN_KEIN:
					{
						connections[cn].state= CONNECT_JOIN;
						InitJoinGameWho(ch);
						ch->updatable = 1;
						break;
					}
				default: 
					{	//< CSD-031129
						MyLog(0, "CMD_ALL_READY error [%s]", connections[cn].name);
						closeconnection(connections, cn, -303);
						return 1;
					}	//> CSD-031129
				}
				//< CSD-031107
				SendEnvironment(connections, cn);
				SendReadyMoveDate(cn);
				SetArea(ADD_PC_AREA, cn);
				RunArea(connections);
				//> CSD-031107
				packet->h.header.type = SealStoneBreakable;
				packet->h.header.size = 0;					
				QueuePacket(connections, cn, packet, 1);

				SendLog2ChrLogDB( connections, cn, CHR_LOG_LOGIN_ );
				CheckAndSendChangeEquip(ch, 1);	// 020620 YGI
				break;
			}	//> CSD-HK-030829
		case CMD_USER_REMOVE:
			{
				SetArea(REMOVE_PC_AREA, cn);
				connections[cn].state = CONNECT_LOGIN;
				break;
			}

⌨️ 快捷键说明

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