Skip to content

Instantly share code, notes, and snippets.

@imerr
Created September 29, 2013 22:54
Show Gist options
  • Save imerr/6757313 to your computer and use it in GitHub Desktop.
Save imerr/6757313 to your computer and use it in GitHub Desktop.
void __cdecl GiveExp(CHARACTER *from, CHARACTER *to, int iExp)
{
signed int delta; // ecx@1
CHARACTER *v4; // edi@1
CHARACTER *from_; // edx@1
CHARACTER *to_; // eax@1
int iExp_; // ecx@1
int delta_empire; // esi@3
int v9; // eax@5
int v10; // ecx@10
signed int v11; // eax@11
int exp; // ebx@20
int v13; // ebx@20
signed int v14; // esi@21
unsigned int v15; // eax@21
signed __int64 v16; // qax@22
char v17; // si@22
int v18; // ebx@23
int v19; // ecx@25
int v20; // ebx@25
int v21; // esi@26
int v22; // eax@28
int v23; // edx@28
int v24; // ebx@28
int v25; // ebx@39
int v26; // esi@41
int v27; // ebx@41
int v28; // eax@41
int v29; // eax@50
CHARACTER *v30; // [sp+14h] [bp-34h]@1
int current_exp; // [sp+18h] [bp-30h]@20
CHARACTER *v32; // [sp+1Ch] [bp-2Ch]@25
int delta_; // [sp+20h] [bp-28h]@1
int v34; // [sp+24h] [bp-24h]@20
int v35; // [sp+28h] [bp-20h]@21
char a2[4]; // [sp+30h] [bp-18h]@22
char v37; // [sp+35h] [bp-13h]@54
char v38; // [sp+37h] [bp-11h]@22
int v39; // [sp+38h] [bp-10h]@1
v4 = from_;
v30 = to_;
v39 = *(_DWORD *)_stack_chk_guard;
delta = iExp_ * aiPercentByDeltaLev[MINMAX(0, to_->m_points.level + 15 - from_->m_points.level, 30)];
delta_ = delta / 100;
if ( distribution_test_server )
delta_ = 3 * delta / 100;
delta_empire = delta_ * (CPrivManager__GetPriv(singleton_CPrivManager___ms_singleton, v4, 4u) + 100) / 100;
if ( CHARACTER__IsEquipUniqueItem(v4, UNIQUE_ITEM_LARBOR_MEDAL) )
delta_empire += delta_empire / 5;
v9 = v4->CEntity.m_lMapIndex;
if ( v9 > 659999 )
{
if ( v9 <= 669999 )
delta_empire += delta_empire / 5;
}
if ( CHARACTER__GetPoint(v4, POINT_EXP_DOUBLE_BONUS) )
{
v25 = number_ex(1, 100, "char_", 2345);
if ( v25 <= CHARACTER__GetPoint(v4, POINT_EXP_DOUBLE_BONUS) )
delta_empire += 30 * delta_empire / 100;
}
if ( CHARACTER__IsEquipUniqueItem(v4, 70005u) )
delta_empire += delta_empire / 2;
v10 = v4->m_dwMountVnum - 20110;
if ( (unsigned int)v10 <= 15 )
{
v11 = 1 << v10;
if ( (1 << v10) & 0xFC10 )
{
delta_empire += 30 * delta_empire / 100;
}
else
{
if ( v11 & 0xF )
{
if ( CHARACTER__IsEquipUniqueItem(v4, 71115u)
|| CHARACTER__IsEquipUniqueItem(v4, 71117u)
|| CHARACTER__IsEquipUniqueItem(v4, 71119u)
|| CHARACTER__IsEquipUniqueItem(v4, 71121u) )
delta_empire += delta_empire / 10;
}
}
}
if ( CHARACTER__IsEquipUniqueGroup(v4, 10060u) )
delta_empire = 0;
if ( CHARACTER__GetPremiumRemainSeconds(v4, 0) > 0 )
delta_empire += delta_empire / 2;
if ( CHARACTER__IsEquipUniqueGroup(v4, UNIQUE_GROUP_RING_OF_EXP) )
delta_empire += delta_empire / 2;
if ( CHARACTER__IsEquipUniqueGroup(v4, 0x274Du) > 0 )
delta_empire += 200 * delta_empire / 100;
exp = delta_empire * CHARACTER__GetMarriageBonus(v4, UNIQUE_ITEM_MARRIAGE_EXP_BONUS, 1) / 100 + delta_empire;
v13 = exp * CHARACTER__GetPoint(v4, POINT_RAMADAN_CANDY_BONUS_EXP) / 100 + exp;
v34 = v13 + v13 * CHARACTER__GetPoint(v4, POINT_MALL_EXPBONUS) / 100;
current_exp = CHARACTER__GetPoint(v4, POINT_EXP);
if ( test_server )
{
v26 = CHARACTER__GetPoint(v4, POINT_EXP);
v27 = CHARACTER__GetPoint(v4, POINT_MALL_EXPBONUS);
v28 = CHARACTER__GetPoint(v4, POINT_RAMADAN_CANDY_BONUS_EXP);
sys_log(0, "Bonus Exp : Ramadan Candy: %d MallExp: %d PointExp: %d", v28, v27, v26);
}
v14 = (v34 + current_exp * v34 / 100)
* CHARACTER_MANAGER__GetMobExpRate(singleton_CHARACTER_MANAGER___ms_singleton, v4);
v15 = CHARACTER__GetNextExp(v4);
v35 = MIN(v15 / 10, v14 / 100);
if ( test_server )
{
std__string__string(a2, "exp_bonus_log", &v38);
LODWORD(v16) = quest__CQuestManager__GetEventFlag(singleton_quest__CQuestManager___ms_singleton, a2);
v17 = 0;
if ( (_DWORD)v16 )
v17 = delta_ > 0;
v18 = *(_DWORD *)a2 - 12;
if ( (char *)(*(_DWORD *)a2 - 12) != std__string___Rep___S_empty_rep_storage )
{
v29 = _gthread_active_8;
if ( _gthread_active_8 < 0 )
{
if ( pthread_once )
{
pthread_mutex_lock(&__gthread_active_p_void_____gthread_active_mutex);
pthread_once(&__gthread_active_p_void_____gthread_active_once, (void (*)(void))__gthread_trigger);
pthread_mutex_unlock(&__gthread_active_p_void_____gthread_active_mutex);
}
if ( _gthread_active_8 < 0 )
_gthread_active_8 = 0;
v29 = _gthread_active_8;
}
if ( v29 )
{
LODWORD(v16) = __gnu_cxx____exchange_and_add(v18 + 8, -1);
HIDWORD(v16) = v16;
}
else
{
HIDWORD(v16) = *(_DWORD *)(v18 + 8);
LODWORD(v16) = HIDWORD(v16) - 1;
*(_DWORD *)(v18 + 8) = HIDWORD(v16) - 1;
}
if ( HIDWORD(v16) <= 0 )
LODWORD(v16) = std__string___Rep___M_destroy(v18, &v37);
}
if ( v17 )
{
HIDWORD(v16) = 100 * (v35 - delta_);
CHARACTER__ChatPacket(v4, 1, "exp bonus %d%%", (v16 >> 32) / delta_);
}
}
v20 = AdjustExpByLevel(v4, v35);
CHARACTER__PointChange(v4, POINT_EXP, v20, 1, 0);
CHARACTER__CreateFly(v30, 1u, v4);
v32 = CHARACTER__GetMarryPartner(v4);
if ( v32 )
{
v21 = 2000 * v20 / v4->m_points.level / v4->m_points.level / 3;
if ( CHARACTER__GetPremiumRemainSeconds(v4, 5u) > 0 || CHARACTER__GetPremiumRemainSeconds(v32, 5u) > 0 )
v21 *= 3;
v22 = marriage__CManager__Get(singleton_marriage__CManager___ms_singleton, v4->m_dwPlayerID);
v24 = v22;
if ( v22 )
{
if ( marriage__TMarriage__IsNear(v19, v23, v22) )
marriage__TMarriage__Update(v24, v21);
}
}
if ( *(_DWORD *)_stack_chk_guard != v39 )
__stack_chk_fail(v19);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment