📄 network.cpp
字号:
void RecvUserRemove( int server_id )
{
LPCHARACTER ch;
connections.receive=1;
ch = ReturnCharacterPoint( server_id );
if( ch == NULL ) { return ; } //JustMsg( "RecvUserRemove" ); return; } // 0521 YGI
if( ch == Hero ) {
ListenCommand = CMD_YOU_REMOVE;
//001209 zhh
closesocket(connections.socket);
return; }
DeleteCharacter( &g_CharacterList, ch );
//printf( "User Remove : %d\n", server_id );
}
int SendUserRemove( void )
{
t_packet packet;
packet.h.header.type = CMD_USER_REMOVE;
packet.h.header.size = 0;
QueuePacket( &packet, 1 );
return( 1 );
}
void RecvNpcAdd( t_server_npc_add *p )
{ //< CSD-030419
LPCHARACTER ch = ReturnCharacterPoint(p->idNpc);
if (ch != NULL)
{
DeleteCharacter(&g_CharacterList, ch);
}
GPCHARINFO gpCharInfo;
memset(&gpCharInfo, 0, sizeof(GPCHARINFO));
strcpy(gpCharInfo.name, LoadMonNameTable(p->nNameNo));
gpCharInfo.type = SPRITETYPE_MONSTER;
gpCharInfo.id = p->idNpc;
gpCharInfo.sprno = p->nSprNo;
gpCharInfo.mutant = p->nMutant;
gpCharInfo.position.x = p->nX;
gpCharInfo.position.y = p->nY;
gpCharInfo.nAttr = p->nAttr;
gpCharInfo.viewtype = VIEWTYPE_NORMAL_;
gpCharInfo.viewtype = p->nViewType;
gpCharInfo.ChairNum = p->nAIType; // LTS AI
gpCharInfo.homex = p->nHomeX;
gpCharInfo.homey = p->nHomeY;
gpCharInfo.eventnpc = p->nEventNpc;
gpCharInfo.bRecallNpc = (p->nRecall == 0) ? false:true;
gpCharInfo.nRace = p->nRace;
switch (gpCharInfo.sprno)
{
case 101:
case 100:
{
gpCharInfo.direction = DIRECTION_RIGHTDOWN;
break;
}
case 50:
case 51:
case 52: // LTS DRAGON BUG
case 63: //荐龋籍1
case 64: //荐龋籍2
case 65: //己巩1
case 66: //己巩2
case 67: //己巩3
case 91:
case 98:
case 99:
case 118:
case 119:
{
gpCharInfo.direction = DIRECTION_DOWN;
break;
}
default:
{
gpCharInfo.direction = DIRECTION(rand()%8);
break;
}
}
gpCharInfo.nCurrentAction = MON1_NONE;
gpCharInfo.basicAction = MON1_NONE;
gpCharInfo.basicWalk = MON1_BATTLE_WALK;
gpCharInfo.animationType = ANIMATION_TYPE_MON1;
gpCharInfo.hp = (p->nStatus >= 2) ? 0:300;
gpCharInfo.mp = 300;
gpCharInfo.sp = 300;
gpCharInfo.hpmax = 300;
gpCharInfo.mpmax = 300;
gpCharInfo.spmax = 300;
gpCharInfo.sex = 0;
gpCharInfo.accessory[0] = 0;
gpCharInfo.accessory[1] = 0;
gpCharInfo.accessory[2] = 0;
gpCharInfo.accessory[3] = 0;
gpCharInfo.nk3 = 0;
gpCharInfo.nk4 = 0;
gpCharInfo.nk6 = 0;
AddCharacter(&g_CharacterList, g_CharacterList.lpLast, &gpCharInfo);
++NPCCOUNT;
connections.receive = 1;
} //> CSD-030419
void RecvNpcRemove( int npc_id )
{
LPCHARACTER ch = ReturnCharacterPoint( npc_id );
if( ch == NULL ) return;
////////////////////// 捞痹绕 0101 /////////////////////////////////////
if( ch->dieani > 32 && ch->nCurrentAction == MON1_DIE)
{
ch->diedelay = 3;
ch->dieani = 32;
}
else
{
DeleteCharacter( &g_CharacterList, ch );
}
NPCCOUNT --;
connections.receive=1;
}
void CalcTacticsSkillExp( int tac_skill, DWORD exp, char step )
{
SCharacterData.TacticsExp[ tac_skill] = exp;
int a = tac_skill;
Hero->aStepInfo[a + TAC_INDEX] = step;
SCharacterData.SkillId[a+88] = GetLeveByExp(Hero->aStepInfo[a + TAC_INDEX],
SCharacterData.TacticsExp[a]);
SCharacterData.TacticsExpNext[a] = NPC_Lev_Ref[SCharacterData.SkillId[a+88]].nMaxExp;
}
//############################## bank ####################################
void SendBankInfo(int type, int money);
//void RecvBankDeposit(int money, int char_money);
//void RecvBankRepayment(int, int, int, DWORD c);
void RecvBankDeposit(DWORD money)
{
SCharacterData.BankMoney = money;
connections.receive=1;
}
void RecvBankRepayment(DWORD total, DWORD money, DWORD time)
{
SCharacterData.LoanTotal = total;
SCharacterData.LastLoan = money;
SCharacterData.LastLoan_Time = time;
connections.receive=1;
}
//#########################################################################
int SendCreateCharacter( SCharacter *s )
{
t_packet packet;
// HN_MAKECHARACTER_ARIGENENT_RECT
// HN_MAKECHARACTER_CLASS_RECT
packet.h.header.type = CMD_CREATE_CHAR;
{
strcpy( packet.u.client_create_char.name, s->sCharacterName );
packet.u.client_create_char.gender = s->nCharacterData[ GENDER ];
packet.u.client_create_char.face = s->nCharacterData[ FACE ];
packet.u.client_create_char.age = s->age;
packet.u.client_create_char.arigement = 0; // CSD-030324
packet.u.client_create_char.cloth_r = s->cloth_r;
packet.u.client_create_char.cloth_g = s->cloth_g;
packet.u.client_create_char.cloth_b = s->cloth_b;
packet.u.client_create_char.body_r = s->body_r;
packet.u.client_create_char.body_g = s->body_g;
packet.u.client_create_char.body_b = s->body_b;
switch( s->nCharacterData[ GENDER ] )
{
case 0 : packet.u.client_create_char.tactics = s->nCharacterData[ TACTICS_WOMAN ]; break;
case 1 : packet.u.client_create_char.tactics = s->nCharacterData[ TACTICS_MAN ]; break;
}
packet.u.client_create_char.Class = s->nCharacterData[ CLASS ];
packet.u.client_create_char.job = s->nCharacterData[ JOB ];
packet.u.client_create_char.spell = s->nCharacterData[ SPELL ];
// packet.u.client_create_char.str = s->nCharacterAbility[STR];
// packet.u.client_create_char.con = s->nCharacterAbility[CON];
// packet.u.client_create_char.dex = s->nCharacterAbility[DEX];
// packet.u.client_create_char.wis = s->nCharacterAbility[WIS];
// packet.u.client_create_char.intl = s->nCharacterAbility[INT];
// packet.u.client_create_char.movp = s->nCharacterAbility[MOVP];
// packet.u.client_create_char.cha = s->nCharacterAbility[CHA];
// packet.u.client_create_char.endu = s->nCharacterAbility[ENDU];
// packet.u.client_create_char.mor = s->nCharacterAbility[MOR];
// packet.u.client_create_char.luck = s->nCharacterAbility[LUCK];
// packet.u.client_create_char.wsps = s->nCharacterAbility[WSPS];
}
packet.h.header.size = sizeof( t_client_create_char );
QueuePacket( &packet, 1 );
double StartTime, Duration;
StartTime = ::timeGetTime( );
ListenCommand = CMD_NONE;
while ( 1 )
{
Duration = ::timeGetTime( ) - StartTime;
if ( Duration > WAIT_TIME_RESPONSE_DURATION ) // 030930 kyo
return( -1 );
if ( HandleRunning(&connections ) <= 0 )
{
Release( &connections);
return( -2 );
}
if ( ListenCommand == CMD_ACCEPT_CREATE )
{
return( TRUE );
}
if ( ListenCommand == CMD_INVALID_DB )
{
return( -1 );
}
}
return TRUE;
}
int SendDeleteCharacter( const char *szName, const char *szSecretKeyCode)
{
t_packet packet;
packet.h.header.type = CMD_DELETE_CHAR;
packet.h.header.size = sizeof( t_client_delete_char );
{
strcpy( packet.u.client_delete_char.name, szName );
strcpy( packet.u.client_delete_char.szSecretKeyCode,szSecretKeyCode);//020730 lsw
}
QueuePacket( &packet, 1 );
double StartTime, Duration;
StartTime = ::timeGetTime( );
ListenCommand = CMD_NONE;
while ( 1 )
{
Duration = ::timeGetTime( ) - StartTime;
if ( Duration > WAIT_TIME_RESPONSE_DURATION ) // 030930 kyo
return( -1 );
if ( HandleRunning(&connections ) <= 0 )
{
Release( &connections);
return( -2 );
}
if ( ListenCommand == CMD_ACCEPT_DELETE )
{
return( TRUE );
}
}
return TRUE;
}
int SendChoiceCharacter( int ch )
{
if( SysInfo.notconectserver ) {return 0;}
t_packet packet;
packet.h.header.type = CMD_CONNECT_INFO;
packet.h.header.size = sizeof( client_connect_info );
memcpy( packet.u.client_connect_info.name, LoadCh[ch].sCharacterName, NM_LENGTH );
memcpy( HeroName, LoadCh[ch].sCharacterName, NM_LENGTH );
packet.u.client_connect_info.startmap = StartMap;
packet.u.client_connect_info.startposition = StartPosition;
QueuePacket( &packet, 1 );
return TRUE;
// 弊府绊 促澜篮 Loading拳搁俊辑 拌加等促.
// Loading拳搁俊辑 CONNECT_INFO啊 朝酒棵锭鳖瘤 ....
}
// User啊 父电 Character沥焊甫 罐绰促.
// LogIn第俊 罐绰 Data....
void Recv4Character( t_server_accept_login *p )
{
HeroServerID = p->server_id;
#ifdef JAPAN_LOCALIZING_
strcpy( connections.id, p->id );
strcpy( IIDD, p->id );
#endif
for( int l = 0 ; l < MAX_CHARACTEROFID ; l ++)
{
EatRearWhiteChar( p->name[l] );
memcpy( LoadCh[l].sCharacterName, p->name[l], 16 );// 0131 YGI
LoadCh[l].nLevel = p->level[l];
LoadCh[l].nCharacterData[HN_MAKECHARACTER_JOB_RECT] = p->job[l];
LoadCh[l].nCharacterData[HN_MAKECHARACTER_CLASS_RECT] = p->cla[l];
//
LoadCh[l].nMoney = p->money[l];
LoadCh[l].age = 18;//p->age[l]; // 20栏肺 绊沥
LoadCh[l].cloth_r = p->clothr[l];
LoadCh[l].cloth_g = p->clothg[l];
LoadCh[l].cloth_b = p->clothb[l];
LoadCh[l].body_r = p->bodyr[l];
LoadCh[l].body_g = p->bodyg[l];
LoadCh[l].body_b = p->bodyb[l];
LoadCh[l].accessory[0] = p->acc_equip1[l];
LoadCh[l].accessory[1] = p->acc_equip2[l];
LoadCh[l].accessory[2] = p->acc_equip3[l];
LoadCh[l].accessory[3] = p->acc_equip4[l];
LoadCh[l].nCharacterData[ GENDER ] = p->gender[l];
LoadCh[l].nation = p->nation; // 0927 YGI
g_nBillingType = p->remained_day; // 0927 YGI
}
connections.receive=1;
}
void RecvHeroInit( t_server_user_db_data *p )
{
SCharacter &ch = SCharacterData;
GPCHARINFO gpCharInfo = {0,};
gpCharInfo.type = SPRITETYPE_CHARACTER;
gpCharInfo.id = HeroServerID;
gpCharInfo.sprno = p->sprno;
gpCharInfo.sex = p->sprno;
gpCharInfo.position.x = p->x;
gpCharInfo.position.y = p->y;
gpCharInfo.direction = DIRECTION_DOWN;
gpCharInfo.nCurrentAction = ACTION_NONE;
gpCharInfo.basicAction = ACTION_BATTLE_NONE;
gpCharInfo.basicWalk = ACTION_BATTLE_WALK_OWNHAND;
gpCharInfo.animationType = ANIMATION_TYPE_WOMAN;
ch.nCharacterHP = gpCharInfo.hp = p->nLife;
ch.nCharacterMAXHP = gpCharInfo.hpmax = p->nMaxHp;
ch.nCharacterMP = gpCharInfo.mp = p->nMana;
ch.nCharacterMAXMP = gpCharInfo.mpmax = p->nMaxMp;
ch.nCharacterSP = gpCharInfo.sp = p->nHungry;
ch.nCharacterMAXSP = gpCharInfo.spmax = p->nMaxHungry;
gpCharInfo.face = p->Attr[1];
// 瓷仿摹 眠啊 ###################################################### // 1213_2
for( int a=0; a<11; a++ )
ch.nCharacterAbility[a] = p->Avility[a];
ch.nMoney = p->money;
ch.nLevel = p->lev;
ch.nExp = p->exp;
ch.nCharacterData[GENDER] = p->Attr[0];
ch.nCharacterData[FACE] = p->Attr[1];
// ch.nCharacterData[ARIGEMENT]= p->Attr[2]; // CSD-030324
ch.nCharacterData[CLASS] = p->Attr[3];
gpCharInfo.spell = ch.nCharacterData[SPELL] = p->Attr[4];
ch.nCharacterData[TACTICS_WOMAN]=p->Attr[5];
ch.nCharacterData[TACTICS_MAN] = p->Attr[5];
ch.condition = p->condition;
memcpy(&gpCharInfo.name_status, &p->nation, sizeof(DWORD)); // CSD-031001
if( gpCharInfo.name_status.counselor )
{
p->acc_equip1 = 114;
p->acc_equip2 = 1; // 秋杆捞 绝促.
}
gpCharInfo.accessory[0] = p->acc_equip1;
if( p->acc_equip1 != 0 ) {
LoadHeroClothAccessoryDataOne( p->sprno, p->acc_equip1 );
LoadHeroClothAccessoryDataOne( p->sprno, p->acc_equip1+1 ); }
gpCharInfo.accessory[1] = p->acc_equip2;
LoadHeroClothAccessoryDataOne( p->sprno, p->acc_equip2 );
gpCharInfo.accessory[2] = p->acc_equip3;
LoadHeroClothAccessoryDataOne( p->sprno, p->acc_equip3 );
gpCharInfo.accessory[3] = p->acc_equip4;
LoadHeroClothAccessoryDataOne( p->sprno, p->acc_equip4 );
// 011030 KHS JJING 卖俊 措茄 何盒篮 咯扁辑 沥狼 窍瘤 臼绊 Equip[8]阑 焊郴林绰 镑俊辑 技泼茄促.
// if( p->jjing >= 5 ) LoadHeroClothAccessoryDataOne( p->sprno, p->acc_equip1+200);
// if( p->jjing >= 9 ) LoadHeroClothAccessoryDataOne( p->sprno, p->acc_equip1+201);
// 011018 KHS 噶肚 ; 咯扁俊绰 噶肚 Data啊 坷瘤 臼绰促. CMD_CHR_ITEM_INFO_1捞 棵锭 equip[WT_NECK]率栏肺 棵锭 贸府茄促.
ch.cloth_r = gpCharInfo.clothr = p->clothr;
ch.cloth_g = gpCharInfo.clothg = p->clothg;
ch.cloth_b = gpCharInfo.clothb = p->clothb;
ch.body_r = gpCharInfo.bodyr = p->bodyr;
ch.body_g = gpCharInfo.bodyg = p->bodyg;
ch.body_b = gpCharInfo.bodyb = p->bodyb;
memcpy( gpCharInfo.name, p->name, 20 );
gpCharInfo.peacests = 0; // 弥檬俊绰 公炼扒 乞拳惑怕肺 登绢 乐促. 0410
ch.potion_box1 = p->sight; // 咯扁辑 sight甫 促弗单促啊 捞侩茄促. //020425
gpCharInfo.Age = 18;//p->Age; // 20栏肺 绊沥
CurOpenHouse = p->openhouse;
ch.LvUpPoint = p->reserved_point;
gpCharInfo.viewtype = p->viewtype;
char *tt;
tt = EatRearWhiteChar( p->mapname );
if( SysInfo.notconectserver == 0 && SysInfo.entergameserver )
{
}
else
memcpy( MapName, tt, 20 );
gpCharInfo.social_status = p->social_status;
ch.nation = gpCharInfo.name_status.nation; // 1004 YGI
gpCharInfo.fame = p->fame;
gpCharInfo.nk3 = p->nk3;
gpCharInfo.nk4 = p->nk4;
gpCharInfo.nk6 = p->nk6;
gpCharInfo.NWCharacter = p->NWCharacter; // 010915 LTS
gpCharInfo.lv = ch.nLevel; // 0807 YGI
gpCharInfo.class_type = ch.nCharacterData[CLASS]; // 0807 YGI
gpCharInfo.nRace = HUMAN; // CSD-030422
AddCharacter( &g_CharacterList, NULL, &gpCharInfo );
memcpy(Hero->name, HeroName, NM_LENGTH);
strcpy(ch.sCharacterName, HeroName); // CSD-031210
memcpy(Hero->aStepInfo, p->aStepInfo, sizeof(Hero->aStepInfo));
Hero->SetGuildCode(p->Attr[2]); // CSD-031001 // thai2 YGI
if (g_StartMenuOn)
{ //1218 YGI
ReqItemInfo0();
}
connections.receive = 1;
}
void RecvEnvironmentInfo( t_server_envir_info *p )
{
WeatherDataProcess( p->weather_count, p->currtime_count,
p->rainstart, p->rainend, p->amount, p->temperature );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -