📄 network.cpp
字号:
packet.u.ClientAccessLogin.Corp_Code = LineNum;
::strcpy(packet.u.ClientAccessLogin.GateWayIP,g_pBill->ReturnIPaddress());
::strcpy(packet.u.ClientAccessLogin.User_ID,g_pBill->ReturnUserID());
packet.u.ClientAccessLogin.GateWayPORT = g_pBill->ReturnPORTNumber();
}
else
{
packet.u.ClientAccessLogin.Corp_Code = 0;
::strcpy(packet.u.ClientAccessLogin.GateWayIP,"");
::strcpy(packet.u.ClientAccessLogin.User_ID,"");
packet.u.ClientAccessLogin.GateWayPORT = 0;
}
::QueuePacket( &packet, 1 );
DWORD StartTime = ::timeGetTime();
ListenCommand = CMD_NONE;
while ( 1 )
{
const DWORD Duration = ::timeGetTime( ) - StartTime;
if ( Duration > 8000 )
{
return( -1 );
}
if ( ::HandleRunning( c ) <= 0 )
{
::Release( c );
return( -2 );
}
switch(ListenCommand)
{
case CMD_INVALID_ID: { return( -3 ); }break;
case CMD_INVALID_PW: { return( -4 ); }break;
case CMD_USED_ID: { return( -5 ); }break;
case CMD_INVALID_VERSION: { return( -6 ); }break;
case CMD_INVALID_DB: { return( -7 ); }break;
case CMD_NOT_EXIST_GAMESERVER: { return( -8 ); }break;
case CMD_INVALID_PAY: { return( -10 ); }break;
case CMD_SO_MUCH_LOGINUSER_WAIT_FOR_A_MIN: { return( -11 ); }break;
case CMD_LOGIN_FAIL_MASSAGE: { return( -12 ); }break;
case CMD_RM_NOW_REPAIR: { return( -13 ); }break;
case CMD_INVALID_AGE: { return( -17 ); }break; // 030929 kyo
case CMD_ACCEPT_LOGIN:
{
::memcpy( c->id, ID, ID_LENGTH );
::memcpy( c->pw, PW, PW_LENGTH );
c->state = CONNECT_LOGIN;
return( 1 );
}break;
}
}
return -8;
}
void SendInstallType( void )
{
}
void SendAllReady( void )
{
t_packet packet;
packet.h.header.type = CMD_ALL_READY;
packet.u.all_ready.x = Hero->x;
packet.u.all_ready.y = Hero->y;
if( GetSysInfo( SI_GAME_MAKE_MODE ) )
if( SysInfo.notconectserver == 0 && SysInfo.entergameserver )
{
packet.u.all_ready.x = Hero->x = SysInfo.mapx * 32;
packet.u.all_ready.y = Hero->y = SysInfo.mapy * 32;
Hero->position.x = SysInfo.mapx;
Hero->position.y = SysInfo.mapy;
StartSetView( Hero );
}
packet.h.header.size = sizeof( t_all_ready );
QueuePacket( &packet, 1 );
// 021117 YGI
#ifdef LIGHT_VERSION_
CallServer( CMD_MOVEMAP_FOR_LIGHT_VERSION ); // light 滚傈捞扼绰 荤角阑 辑滚俊 舅赴促.
#endif
if( GetSysInfo( SI_GAME_MAKE_MODE ) ) Log( "甘捞悼.txt", "CMD_ALL_READY" );
SendInstallType();
SendRequestTileDontData(); // 010904 LTS //甘捞悼魄窜.. //惫啊傈 甘捞搁.. //酒惫利焙//傈里乞拳 惑包绝澜..
SendCMD_REQUEST_COMPARE_PHASE(); // LTS LOCALWAR
}
// 010515 KHS
void SendMoveData( LPCHARACTER ch )
{
t_packet packet;
int i;
int dir;
int bOdd;
char szData[ MAX_PATH] = {0, };
int nx, ny, px, py;
int c = 0;
if( ch->eventnpc ) return;
bOdd = 0;
if( ch->pathcount > 2 )
{
px = ch->path[ch->pathcount-1][0];
py = ch->path[ch->pathcount-1][1];
for( i = ch->pathcount-2 ; i >= 0 ; i --)
{
nx = ch->path[i][0];
ny = ch->path[i][1];
if ( nx > px )
{
if ( ny > py ) { dir = 7; }
else if ( ny < py ) { dir = 5; }
else { dir = 6; }
}
else if ( nx < px )
{
if ( ny > py ) { dir = 1; }
else if ( ny < py ) { dir = 3; }
else { dir = 2; }
}
else
{
if ( ny > py ) { dir = 0; }
else { dir = 4; }
}
if ( bOdd == 0){ szData[ (c/2) ] = dir << 4; }
else { szData[ (c/2) ] += dir; }
c++;
bOdd = !bOdd;
px = nx;
py = ny;
}
}
packet.h.header.type = CMD_MOVE;
{
packet.u.client_move.server_id = ch->id;
packet.u.client_move.length = ch->pathcount;
packet.u.client_move.movep = ch->MoveP; // NPC父 康亲阑 固魔..
packet.u.client_move.movetype = ch->movetype;
packet.u.client_move.sx = (short int )ch->x/ TILE_SIZE;
packet.u.client_move.sy = (short int )ch->y/ TILE_SIZE;
memcpy( packet.u.client_move.dir_tbl, szData, (ch->pathcount+1)/2 );
packet.u.client_move.gox = ch->gox;
packet.u.client_move.goy = ch->goy;
}
packet.h.header.size = sizeof( t_client_move ) - MAX_DIR_TABLE + (ch->pathcount+1)/2;
QueuePacket( &packet, 1 );
if( ch->id == Hero->id )
{
Hero->oldpathcount = Hero->pathcount;
if( CheckLineCollision( Hero, Hero->x/ TILE_SIZE, Hero->y/ TILE_SIZE, Hero->gox/TILE_SIZE, Hero->goy / TILE_SIZE ) )
{
Hero->pathcount = 0;
}
}
}
//-----------------------------------------------------------------------------
// movetype - 0:walk 1:run
// 010724 KHS
void RecvMoveData( t_server_move *p )
{
int count, bOdd, i, t, dir;
int movetype, sx, sy, len;
unsigned char *tbl;
int gox, goy;
CHARACTER tch;
bool linecollisioncheck;
bool remakepath = false;
if( g_CurrentTime == 0 ) return;
LPCHARACTER ch = ReturnCharacterPoint( p->server_id );
if( ch == NULL )
{
return;
}
if( IsDead( ch ) && ch->viewtype != VIEWTYPE_GHOST_ ) return;
switch (ch->sprno)
{
case 0:
case 1: break;
default:
{
if (ch->nCurrentAction == MON1_BATTLE_MAGIC)
{
return;
}
break;
}
}
if( Hero == ch )
{
CharWalkTime( ch, ch->nCurrentAction );
ch->desttime = p->desttime;
int temppathcount = ch->pathcount;
ch->pathcount = ch->oldpathcount;
CharCalcMovP( ch );
ch->pathcount = temppathcount;
return;
}
else
{
//acer
if( ch->viewtype == VIEWTYPE_STONE_ )
ch->viewtype = VIEWTYPE_NORMAL_;
}
len = p->length;
tbl = p->dir_tbl;
sx = p->sx;
sy = p->sy;
gox = p->gox;
goy = p->goy;
movetype = p->movetype;
ch->pathcount = len;
if( p->movetype >= 100 ) // 厘力 困摹 Setting.... // 0 : 叭扁 1 : 顿扁.
{
p->movetype -= 100;
ch->x = sx * TILE_SIZE + 16;
ch->y = sy * TILE_SIZE + 16;
}
linecollisioncheck = false;
if( CheckLineCollision( ch, ch->x/ TILE_SIZE, ch->y/TILE_SIZE, p->gox/TILE_SIZE, p->goy / TILE_SIZE ) )
{
if( ch->pathcount >= 1000 ) ch->pathcount -= 1000;
linecollisioncheck = true;
goto NEXT_;
}
// 010905 KHS
TileMap[ ch->position.x][ch->position.y].occupied = 0;
ch->position.x = p->sx;
ch->position.y = p->sy;
if (ch->hp>0) TileMap[ ch->position.x][ch->position.y].occupied = 1; // 010915 LTS
ch->oldposition.x = p->sx;
ch->oldposition.y = p->sy;
bOdd =0;
count =0;
if( p->length > 1000 )
{ bOdd++; count ++; p->length -= 1000; }
if( len > 1000 ) len -=1000;
{ // 辑滚狼 Data措肺 啊瘤 臼绊 促矫 PathBuild()茄促....
memcpy( &tch, ch, sizeof( CHARACTER ) );
tch.moveFlag = TRUE;
tch.movetype = movetype;
tch.gox = gox;
tch.goy = goy;
int mx = gox / TILE_SIZE;
int my = goy / TILE_SIZE;
tch.destx = mx, tch.desty = my;
if( PathBuild( &tch ) && TileMap[ ch->x/ TILE_SIZE][ch->y/TILE_SIZE].attr_dont == 0)
{
//if( GetSysInfo( SI_GAME_MAKE_MODE ) ) AddCurrentStatusMessage( 100,100,255 , "促矫 父甸绢 捞悼钦聪促.");//( %d %d %d %d )", p->server_id, p->gox, p->goy, p->length, p->desttime );
memcpy( ch, &tch, sizeof( CHARACTER ) );
remakepath = true;
goto NEXT_;
}
else
{
///if( GetSysInfo( SI_GAME_MAKE_MODE ) ) AddCurrentStatusMessage( 255,100,255 , "辑滚Data肺 捞悼钦聪促.");//( %d %d %d %d )", p->server_id, p->gox, p->goy, p->length, p->desttime );
}
}
if( len != 0 )
{
ch->path[len-1][0] = sx;
ch->path[len-1][1] = sy;
for( i = 1 ; i < len ; i ++)
{
t = count /2;
if( bOdd == 0) dir = (*(tbl+t) >> 4) & 0x0f;
else dir = *(tbl+t) & 0x0f;
bOdd = !bOdd; count ++;
switch( dir )
{
case 0 : sy ++; break;
case 1 : sx --; sy ++; break;
case 2 : sx --; break;
case 3 : sx --; sy --; break;
case 4 : sy --; break;
case 5 : sx ++; sy --; break;
case 6 : sx ++; break;
case 7 : sx ++; sy ++; break;
}
ch->path[len-i-1][0] = sx;
ch->path[len-i-1][1] = sy;
}
}
NEXT_:
if( ch->pathcount > 1000 ) ch->pathcount -=1000;
if( movetype == 0 )
{
if( ch->pathcount > 5 ) movetype = 1;
}
ch->moveFlag = TRUE;
ch->gox = gox;
ch->goy = goy;
CharDoAni_Moving( ch, movetype );
if( p->server_id >= 10000 )
{
ch->movetargetid = p->targetid;
}
CharWalkTime( ch, ch->nCurrentAction );
ch->desttime = p->desttime;
CharCalcMovP( ch );
connections.receive = 1;
if( linecollisioncheck == true )
{
ch->pathcount = 0;
return;
}
if( remakepath == true )
if( CheckLineCollision( ch, p->sx, p->sy, p->gox/TILE_SIZE, p->goy / TILE_SIZE ) )
{
ch->pathcount = 0;
}
};
void GetRealTime( int &mon, int &day, int &hour )
{
short int time = g_RealDate;
mon = time>>10;
time -= mon<<10;
day = time >> 5;
time -= day << 5;
hour = time;
}
void RecvWeatherData(t_server_weather* p)
{ //< CSD-CN-031217
if (g_bStopWeatherSystem)
{
return;
}
if (g_bOffWeatherSystem)
{
WeatherDataProcess(p->weather, p->another, 0, 0, 0, 0);
}
else
{
WeatherDataProcess(p->weather, p->another, p->rainstart, p->rainend, p->amount, p->temperature);
}
} //> CSD-CN-031217
void RecvAddItem( t_server_item_add *p )
{
ITEMGROUND i;
if( FindItemList( p->item_id ) ) return;
i.server_id = p->item_id;
i.no = (WORD)p->item.item_no; // 020701 YGI
i.x = p->x;
i.y = p->y;
i.offx = p->offx;
i.offy = p->offy;
i.attr[0] = p->item.attr[0];
i.attr[1] = p->item.attr[1];
i.attr[2] = p->item.attr[2];
i.attr[3] = p->item.attr[3];
i.attr[4] = p->item.attr[4];
i.attr[5] = p->item.attr[5];
AddItemList( &i);
connections.receive=1;
}
//攫笼 this lsw
void Unzip(BYTE *pbIn, int iSize, BYTE *pbOut)
{
int iStatusSize = pbIn[0];
int iInPos = iStatusSize+1; // input buf狼 index
int iOutPos = 0;
for( int i=0; i<iStatusSize; i++ )
{
unsigned char cFlag = pbIn[i+1];
for( int j=0; j< 8 ; j++, iOutPos++ )
{
if( cFlag & 0x01 )
{
pbOut[iOutPos] = pbIn[iInPos++];
}
else pbOut[iOutPos] = 0;
cFlag = cFlag >> 1;
}
}
}
void RecvAddItemZiped( t_server_item_add_ziped *p)
{
t_packet unziped;
Unzip((BYTE *)p,p->zipedpack[0],(BYTE*)&unziped.u.server_item_add);
RecvAddItem( &unziped.u.server_item_add );
}
void RecvRemoveItem( int item_id )
{
DeleteItemList( item_id );
connections.receive=1;
}
void RecvYouGotItem( int item_id ) // 0109
{
LPITEMGROUND i = FindItemList( item_id );
if( i != NULL )
{
HandItemAttr.attr[0] = i->attr[0]; //1214
HandItemAttr.attr[1] = i->attr[1];
HandItemAttr.attr[2] = i->attr[2];
HandItemAttr.attr[3] = i->attr[3];
HandItemAttr.attr[4] = i->attr[4];
HandItemAttr.attr[5] = i->attr[5];
HandItemAttr.item_no = i->no;
g_MouseItemType = 1;
g_MouseItemNumber = i->no;
SetItemPos( GROUND, 0, &IP_base );
ItemSoundOfGetItem( i->no );
DeleteItemList( item_id ); //acer7
}
connections.receive=1;
}
void SendDropItem( int itemno, int x, int y, unsigned int attr[6] )
{
t_packet packet;
packet.h.header.type = CMD_ITEM_DROP;
{
packet.u.client_item_drop.item.item_no = itemno;
packet.u.client_item_drop.item.attr[0] = attr[0];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -