Master Summoner
- Joined
- Jun 12, 2007
- Messages
- 513
- Reaction score
- 170
I'm trying to manipulate this function, but in order to do that all the rest functions needs to be correct.
the problem is that the function is huge, and because of this it gets very confusing.
Here is what I've managed so far, but it crashes the mainsvr.
I'm very aware that Ida may show invalid args and commands, but that's why I'm turning to you guys now.
Any idéas?
the problem is that the function is huge, and because of this it gets very confusing.
Code:
int __fastcall CPlayer__OnLoadPlayer(int *a2, int __edx)
{
int v1; // edx@1
signed int result; // eax@2
int v3; // edx@4
int v4; // edx@5
int v5; // eax@5
int v6; // eax@5
int v7; // eax@5
int v8; // eax@5
int v9; // eax@5
int v10; // eax@5
int v11; // eax@5
int v12; // eax@5
int v13; // eax@5
int v14; // eax@5
int v15; // eax@5
int v16; // eax@5
int v17; // eax@5
int v18; // eax@5
int v19; // eax@5
int v20; // eax@5
int v21; // eax@5
int v22; // eax@5
int v23; // eax@6
int v24; // eax@18
int v25; // edx@19
int v26; // ecx@21
int v27; // eax@39
int v28; // edx@41
int v29; // ecx@44
int v30; // eax@46
int v31; // edx@54
int v32; // ecx@56
int v33; // eax@59
int v34; // edx@61
int v35; // eax@83
int v36; // eax@88
int v37; // ecx@112
int v38; // edx@113
int v39; // edx@117
int v40; // edx@119
int v41; // edx@120
int v42; // eax@120
int v43; // edx@122
int v44; // [sp+0h] [bp-B0h]@104
int v45; // [sp+4h] [bp-ACh]@97
int v46; // [sp+8h] [bp-A8h]@21
int v47; // [sp+Ch] [bp-A4h]@1
int v48; // [sp+10h] [bp-A0h]@103
int v49; // [sp+14h] [bp-9Ch]@96
char v50; // [sp+24h] [bp-8Ch]@83
char v51; // [sp+2Ch] [bp-84h]@83
__int32 v52; // [sp+4Ch] [bp-64h]@110
int v53; // [sp+50h] [bp-60h]@110
int ii; // [sp+54h] [bp-5Ch]@108
int v55; // [sp+58h] [bp-58h]@106
int n; // [sp+5Ch] [bp-54h]@101
int v57; // [sp+60h] [bp-50h]@99
int m; // [sp+64h] [bp-4Ch]@94
char v59; // [sp+68h] [bp-48h]@88
char v60; // [sp+6Ch] [bp-44h]@88
int v61; // [sp+70h] [bp-40h]@88
int v62; // [sp+74h] [bp-3Ch]@88
int v63; // [sp+78h] [bp-38h]@88
int l; // [sp+7Ch] [bp-34h]@86
int v65; // [sp+80h] [bp-30h]@83
int k; // [sp+84h] [bp-2Ch]@81
int v67; // [sp+88h] [bp-28h]@16
int j; // [sp+8Ch] [bp-24h]@13
int i; // [sp+90h] [bp-20h]@8
unsigned __int8 v70; // [sp+96h] [bp-1Ah]@10
unsigned __int8 v71; // [sp+97h] [bp-19h]@10
int v72; // [sp+98h] [bp-18h]@5
int v73; // [sp+9Ch] [bp-14h]@7
int v74; // [sp+A0h] [bp-10h]@3
int v75; // [sp+A4h] [bp-Ch]@7
int v76; // [sp+A8h] [bp-8h]@7
int v77; // [sp+ACh] [bp-4h]@113
int arg0; // [sp+B8h] [bp+8h]@0
v47 = (int)a2;
Server::CChar::Lock((int)a2);
if ( Server::CPlayer::CPlayer__IsPBit(v47, 4) )
{
Server::CChar::Unlock(v47, v1);
result = 0;
}
else
{
v74 = Server::sub::sub_418960(arg0, v47 + 456);
if ( *(DWORD *)(v47 + 456) == 1 )
{
Server::CPlayer::Write((void*)v47, 67, (const char*)"b");
//Server::CPlayer::Write(this->thispointer, 68,"bs",18,message);
Server::CChar::Unlock(v47, v3);
result = 0;
}
else
{
v5 = Server::sub::sub_497620(v74, v47 + 32);
v6 = Server::sub::sub_418960(v5, v47 + 460);
v7 = Server::sub::sub_418960(v6, v47 + 464);
v8 = Server::sub::sub_418960(v7, v47 + 60);
v9 = Server::sub::sub_418980(v8, v47 + 468);
v10 = Server::sub::sub_47A220(v9, v47 + 472);
v11 = Server::sub::sub_47A240(v10, v47 + 480);
v12 = Server::sub::sub_418960(v11, v47 + 536);
v13 = Server::sub::sub_418960(v12, v47 + 64);
v14 = Server::sub::sub_418960(v13, v47 + 68);
v15 = Server::sub::sub_418960(v14, v47 + 72);
v16 = Server::sub::sub_418960(v15, v47 + 76);
v17 = Server::sub::sub_418960(v16, v47 + 80);
v18 = Server::sub::sub_418980(v17, v47 + 272);
v19 = Server::sub::sub_418980(v18, v47 + 276);
v20 = Server::sub::sub_418980(v19, v47 + 544);
v21 = Server::sub::sub_418980(v20, v47 + 548);
v22 = Server::sub::sub_418960(v21, v47 + 552);
v74 = Server::sub::sub_418960(v22, v47 + 316);
v74 = Server::sub::sub_47A240(v74, (int)&v72);
if ( v72 >= 0 )
{
v74 = Server::sub::sub_47A240(v74, (int)&v73);
v74 = Server::sub::sub_47A240(v74, v47 + 340);
v74 = Server::sub::sub_418960(v74, v47 + 556);
v74 = Server::sub::sub_418960(v74, v47 + 560);
v74 = Server::sub::sub_418960(v74, v47 + 572);
v74 = Server::sub::sub_47A240(v74, v47 + 580);
Server::CChar::CChar__SetXY(v47, (int)&v72);
(*(void (__thiscall **)(int))(*(DWORD *)v47 + 84))(v47);
Server::sub::sub_47F680(v47 + 624, v47);
v76 = 0;
v75 = v74;
v74 = Server::sub::sub_418960(v74, (int)&v76);
if ( v76 )
{
for ( i = 0; i < v76; ++i )
{
v74 = Server::sub::sub_418960(v74, (int)&v71);
v74 = Server::sub::sub_418960(v74, (int)&v70);
Server::sub::sub_47F6B0(v47 + 624, v71, v70);
}
Server::sub::sub_47FC00((void *)(v47 + 624));
Server::CPlayer::Write((void*)v47, 16, (const char*)"m");
}
v74 = Server::sub::sub_418960(v74, (int)&v76);
if ( v76 )
{
Server::CIOCriticalSection::CIOCriticalSection__Enter((int)v47 + 1020);
for ( j = 0; j < v76; ++j )
{
v67 = Server::sub::sub_426060(*(DWORD *)(v47 + 452), &v74);
if ( v67 )
{
if ( Server::CItem::IsState(v67, 1) )
{
v24 = *(DWORD *)(v67 + 48);
if ( v24 & 0x7FF00 )
{
v25 = *(DWORD *)(v67 + 48);
if ( v25 & 0x100000 )
Server::CChar::AddGState(v47, -2147483648);
v26 = *(DWORD *)(v67 + 48);
v46 = v26 & 0x7FF00;
if ( (v26 & 0x7FF00u) > 0x2000 )
{
if ( (unsigned int)v46 > 0x10000 )
{
if ( v46 == 131072 )
{
Server::CChar::AddGState(v47, 536870912);
(*(void (__cdecl **)(int, signed int, signed int, signed int, signed int))(*(DWORD *)v47 + 92))(
v47,
27,
1,
50,
50);
(*(void (__cdecl **)(int, signed int, signed int, signed int, signed int))(*(DWORD *)v47 + 92))(
v47,
28,
1,
50,
50);
}
else
{
if ( v46 == 262144 )
{
Server::CChar::AddGState(v47, 1073741824);
(*(void (__cdecl **)(int, signed int, signed int, signed int))(*(DWORD *)v47 + 92))(
v47,
5,
1,
50);
(*(void (__cdecl **)(int, signed int, signed int, signed int))(*(DWORD *)v47 + 92))(
v47,
6,
1,
50);
(*(void (__cdecl **)(int, DWORD, signed int, signed int))(*(DWORD *)v47 + 92))(v47, 0, 1, 6);
(*(void (__cdecl **)(DWORD, signed int, DWORD, signed int))(*(DWORD *)v47 + 92))(
v47,
2,
1,
6);
(*(void (__cdecl **)(DWORD, signed int, DWORD, DWORD))(*(DWORD *)v47 + 92))(v47, 4, 1, 6);
(*(void (__cdecl **)(int, signed int, signed int, signed int))(*(DWORD *)v47 + 92))(
v47,
3,
1,
10);
(*(void (__cdecl **)(DWORD, signed int, DWORD, signed int))(*(DWORD *)v47 + 92))(
v47,
1,
1,
10);
}
}
}
else
{
switch ( v46 )
{
case 65536:
Server::CChar::AddGState(v47, 268435456);
v33 = *(DWORD *)(v67 + 48);
if ( v33 & 0x80000 )
{
(*(void (__cdecl **)(int, signed int, DWORD, signed int))(*(DWORD *)v47 + 96))(
v47,
5,
0,
5);
(*(void (__cdecl **)(int, signed int, signed int, signed int))(*(DWORD *)v47 + 96))(
v47,
6,
1,
10);
}
else
{
v34 = *(DWORD *)(v67 + 48);
if ( v34 & 0x100000 )
{
(*(void (__cdecl **)(int, signed int, DWORD, signed int))(*(DWORD *)v47 + 96))(
v47,
5,
0,
10);
(*(void (__cdecl **)(int, signed int, signed int, signed int))(*(DWORD *)v47 + 96))(
v47,
6,
1,
20);
}
}
break;
case 16384:
Server::CChar::AddGState(v47, 67108864);
break;
case 32768:
Server::CChar::AddGState(v47, 134217728);
v31 = *(DWORD *)(v67 + 48);
if ( v31 & 0x80000 )
{
(*(void (__cdecl **)(DWORD, DWORD, signed int, DWORD))(*(DWORD *)v47 + 96))(
v47,
5,
1,
10);
(*(void (__cdecl **)(DWORD, signed int, DWORD, signed int))(*(DWORD *)v47 + 96))(
v47,
6,
0,
5);
}
else
{
v32 = *(DWORD *)(v67 + 48);
if ( v32 & 0x100000 )
{
(*(void (__cdecl **)(DWORD, DWORD, DWORD, signed int))(*(DWORD *)v47 + 96))(
v47,
5,
1,
20);
(*(void (__cdecl **)(DWORD, DWORD, DWORD, DWORD))(*(DWORD *)v47 + 96))(v47, 6, 0, 10);
}
}
break;
}
}
}
else
{
if ( v46 == 8192 )
{
Server::CChar::AddGState(v47, 33554432);
}
else
{
if ( (unsigned int)v46 > 0x400 )
{
if ( v46 == 2048 )
{
Server::CChar::AddGState(v47, 8388608);
}
else
{
if ( v46 == 4096 )
Server::CChar::AddGState(v47, 16777216);
}
}
else
{
switch ( v46 )
{
case 1024:
Server::CChar::AddGState(v47, 4194304);
break;
case 256:
Server::CChar::AddGState(v47, 1048576);
v27 = *(DWORD *)(v67 + 48);
if ( v27 & 0x80000 )
{
(*(void (__cdecl **)(DWORD, signed int, DWORD, signed int))(*(DWORD *)v47 + 92))(
v47,
5,
1,
20);
(*(void (__cdecl **)(DWORD, DWORD, DWORD, signed int))(*(DWORD *)v47 + 92))(
v47,
0,
1,
2);
(*(void (__cdecl **)(int, signed int, signed int, signed int))(*(DWORD *)v47 + 92))(
v47,
2,
1,
2);
(*(void (__cdecl **)(DWORD, signed int, DWORD, DWORD))(*(DWORD *)v47 + 92))(
v47,
4,
1,
2);
}
else
{
v28 = *(DWORD *)(v67 + 48);
if ( v28 & 0x100000 )
{
(*(void (__cdecl **)(DWORD, signed int, DWORD, signed int))(*(DWORD *)v47 + 92))(
v47,
5,
1,
50);
(*(void (__cdecl **)(DWORD, DWORD, DWORD, signed int))(*(DWORD *)v47 + 92))(
v47,
0,
1,
3);
(*(void (__cdecl **)(DWORD, DWORD, DWORD, signed int))(*(DWORD *)v47 + 92))(
v47,
2,
1,
3);
(*(void (__cdecl **)(DWORD, DWORD, DWORD, DWORD))(*(DWORD *)v47 + 92))(
v47,
4,
1,
3);
}
}
break;
case 512:
Server::CChar::AddGState(v47, 2097152);
v29 = *(DWORD *)(v67 + 48);
if ( v29 & 0x80000 )
{
(*(void (__cdecl **)(DWORD, signed int, DWORD, signed int))(*(DWORD *)v47 + 92))(
v47,
6,
1,
20);
(*(void (__cdecl **)(DWORD, signed int, DWORD, DWORD))(*(DWORD *)v47 + 92))(
v47,
3,
1,
2);
(*(void (__cdecl **)(DWORD, signed int, DWORD, DWORD))(*(DWORD *)v47 + 92))(
v47,
1,
1,
2);
}
else
{
v30 = *(DWORD *)(v67 + 48);
if ( v30 & 0x100000 )
{
(*(void (__cdecl **)(DWORD, DWORD, DWORD, DWORD))(*(DWORD *)v47 + 92))(
v47,
6,
1,
50);
(*(void (__cdecl **)(DWORD, signed int, DWORD, signed int))(*(DWORD *)v47 + 92))(
v47,
3,
1,
5);
(*(void (__cdecl **)(DWORD, DWORD, DWORD, signed int))(*(DWORD *)v47 + 92))(
v47,
1,
1,
5);
}
}
break;
}
}
}
}
}
}
if ( (*(int (__thiscall **)(int, int))(*(DWORD *)v67 + 148))(v67, v67) || *(DWORD *)(v67 + 52) <= 1 )
{
if ( Server::CPlayer::IntoInven(v67) )
{
if ( (*(int (__thiscall **)(int))(*(DWORD *)v67 + 164))(v67) )
{
*(DWORD *)(v47 + 1096) = v67;
if ( *(DWORD *)(*(DWORD *)(v47 + 1096) + 52) < 0 )
{
Server::Console::WriteRed(
"m_pMoney->m_nNum <0 : UID(%d) PID(%d) IID(%d) Num(%d) ",
*(DWORD *)(v47 + 448),
*(DWORD *)(v47 + 452),
*(DWORD *)(v67 + 36),
*(DWORD *)(*(DWORD *)(v47 + 1096) + 52));
Server::CDBSocket::CDBSocket__Write(8, (unsigned int)"ddwdb");
*(DWORD *)(*(DWORD *)(v47 + 1096) + 52) = 1;
}
}
else
{
if ( (*(int (__thiscall **)(int))(*(DWORD *)v67 + 196))(v67) )
++*(DWORD *)(v47 + 1104);
}
}
else
{
Server::Console::WriteRed("CPlayer::OnLoadPlayer() Item insert error. (IID:%d)", *(DWORD *)(v67 + 36));
Server::CBase::CBase__Delete((void *)v67);
}
}
else
{
Server::Console::WriteRed(
"CPlayer::OnLoadPlayer() Ãi+--",
v47 + 32,
*(DWORD *)(v47 + 452),
*(DWORD *)(v47 + 448),
*(DWORD *)(*(DWORD *)(v67 + 40) + 64),
*(DWORD *)(v67 + 52));
Server::CBase::CBase__Delete((void *)v67);
}
}
}
Server::CIOCriticalSection::CIOCriticalSection__Leave(v47 + 1020);
}
v74 = Server::sub::sub_418960(v74, (int)&v76);
if ( v76 )
{
Server::CIOCriticalSection::CIOCriticalSection__Enter(v47 + 1020);
for ( k = 0; k < v76; ++k )
{
v65 = v74;
v35 = Server::sub::sub_472830((int)&v51, v74 + 2, (const void *)v74);
Server::sub::sub_470890((v47 + 1128), (int)&v50, v35);
v74 += 26;
}
Server::CIOCriticalSection::CIOCriticalSection__Leave(v47 + 1020);
}
v75 = v74;
v74 = Server::sub::sub_418960(v74, (int)&v76);
if ( v76 )
{
for ( l = 0; l < v76; ++l )
{
v61 = 0;
v62 = 0;
v63 = 0;
v74 = Server::sub::sub_418980(v74, (int)&v61);
v74 = Server::sub::sub_418960(v74, (int)&v62);
v74 = Server::sub::sub_418960(v74, (int)&v63);
v36 = Server::sub::sub_472860((int)&v61, (int)&v62);
if ( !v60 )
Server::Console::WriteRed("CPlayer::OnLoadPlayer() Duplicate Quest. (PID:%d, Quest:%d)", *(DWORD *)(v47 + 452), v61);
}
Server::CPlayer::Write((void*)v47, 87, (const char*)"m");
}
if ( Server::CPlayer::dword_4E1178() & 4 )
{
v74 = Server::sub::sub_418960(v74, (int)&v76);
if ( v76 )
{
for ( m = 0; m < v76; ++m )
{
v49 = Server::CIOObject::CObject__GetPointer(0x10u);
if ( v49 )
v45 = Server::sub::sub_457E30(v49);
else
v45 = 0;
v57 = v45;
v74 = Server::sub::sub_418960(v74, v45 + 4);
v74 = Server::sub::sub_47A240(v74, v57 + 8);
Server::CPlayer::EventInsert(v47, v57);
}
}
}
v74 = Server::sub::sub_418960(v74, (int)&v76);
if ( v76 )
{
for ( n = 0; n < v76; ++n )
{
v48 = Server::CIOObject::CObject__GetPointer(0x30u);
if ( v48 )
v44 = Server::sub::sub_457E60(v48);
else
v44 = 0;
v55 = v44;
v74 = Server::sub::sub_418960(v74, v44);
v74 = Server::sub::sub_497620(v74, v55 + 8);
v74 = Server::sub::sub_47A240(v74, v55 + 4);
v74 = Server::sub::sub_47A240(v74, v55 + 40);
v74 = Server::sub::sub_418960(v74, v55 + 28);
v74 = Server::sub::sub_418960(v74, v55 + 32);
Server::CPlayer::CPlayer__MLMLoad(v47, v55);
}
}
v74 = Server::sub::sub_418960(v74, (int)&v76);
if ( v76 )
{
for ( ii = 0; ii < v76; ++ii )
{
v53 = 0;
v52 = 0;
v74 = Server::sub::sub_418960(v74, (int)&v53);
v74 = Server::sub::sub_47A240(v74, (int)&v52);
Server::CChar::CChar__SetBuff(v47, v53, v52);
}
}
if ( Server::CPlayer::IsPCBang(v47) )
{
v37 = *(DWORD *)(v47 + 308);
*(DWORD *)(v47 + 304) |= 1u;
*(DWORD *)(v47 + 308) = v37;
}
v74 = Server::sub::sub_47A240(v74, (int)&v77);
if ( v77
&& (Server::CChar::CChar__Unlock(v47, v38), Server::CGuild::CGuild__Load(v77, v74, 0), Server::CChar::CChar__Lock(v47), Server::CPlayer::CPlayer__IsPBit(v47, 4)) )
{
Server::CChar::CChar__Unlock(v47, v38);
result = 0;
}
else
{
if ( *(DWORD *)(v47 + 480)
&& (Server::CChar::CChar__Unlock(v47, v38), Server::CGuild::CGuild__Login(v47), Server::CChar::CChar__Lock(v47), Server::CPlayer::CPlayer__IsPBit(v47, 4)) )
{
Server::CChar::CChar__Unlock(v47, v39);
result = 0;
}
else
{
if ( Server::CGuild::CGuild__IsWarringPeriod()
&& (Server::CChar::CChar__Unlock(v47, v40),
v42 = Server::CPlayer::CPlayer__GetGID(v47),
Server::CGuild::CGuild__LoginCastle(v47, v42),
Server::CChar::CChar__Lock(v47),
Server::CPlayer::CPlayer__IsPBit(v47, 4)) )
{
Server::CChar::CChar__Unlock(v47, v41);
result = 0;
}
else
{
Server::sub::sub_496CD0();
if ( Server::CPlayer::CPlayer___Create(v47) )
{
Server::CChar::CChar__Unlock(v47, v43);
result = 1;
}
else
{
Server::CChar::CChar__Unlock(v47, v43);
result = 0;
}
}
}
}
}
else
{
Server::CChar::CChar__Unlock(v47, v4);
v23 = Server::sub::sub_422B30("CPlayer::OnLoadPlayer PID(%d) X(%d) Y(%d) \n", *(DWORD *)(v47 + 452));
Server::sub::sub_422D80(v23);
result = 0;
}
}
return result;
}
}
Here is what I've managed so far, but it crashes the mainsvr.
I'm very aware that Ida may show invalid args and commands, but that's why I'm turning to you guys now.
Any idéas?