~ares-developers/ares/gd03

« back to all changes in this revision

Viewing changes to src/Ext/Techno/Hooks.Ammo.cpp

  • Committer: Renegade
  • Date: 2010-05-29 08:12:17 UTC
  • Revision ID: git-v1:0a1bb6321f04d723afe64d1b843dc87b4da783ec
Creating /trunk/src.

git-svn-id: svn://svn.renegadeprojects.com/ares/trunk@622 859b54a9-7a54-0410-aeb3-f8d2f1fa40fd

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "Body.h"
 
2
#include "../../Misc/Debug.h"
 
3
#include "../../Ares.h"
 
4
 
 
5
// bugfix #471: InfantryTypes and BuildingTypes don't reload their ammo properly
 
6
 
 
7
DEFINE_HOOK(43FE8E, BuildingClass_Update_Reload, 6)
 
8
{
 
9
        GET(BuildingClass *, B, ESI);
 
10
        BuildingTypeClass *BType = B->Type;
 
11
        if(!BType->Hospital && !BType->Armory) { // TODO: rethink this
 
12
                B->Reload();
 
13
        }
 
14
        return 0x43FEBE;
 
15
}
 
16
 
 
17
DEFINE_HOOK(6FCFA4, TechnoClass_GetROF_BuildingHack, 5)
 
18
{
 
19
        GET(TechnoClass *, T, ESI);
 
20
        // actual game code: if(auto B = specific_cast<BuildingClass *>(T)) { if(T->currentAmmo > 1) { return 1; } }
 
21
        // if the object being queried doesn't have a weapon (Armory/Hospital), it'll return 1 anyway
 
22
 
 
23
        return 0x6FCFC1;
 
24
}
 
25
 
 
26
DEFINE_HOOK(5200D7, InfantryClass_UpdatePanic_DontReload, 6)
 
27
{
 
28
        return 0x52010B;
 
29
}
 
30
 
 
31
DEFINE_HOOK(51BCB2, InfantryClass_Update_Reload, 6)
 
32
{
 
33
        GET(InfantryClass *, I, ESI);
 
34
        if(I->InLimbo) {
 
35
                return 0x51BDCF;
 
36
        }
 
37
        I->Reload();
 
38
        return 0x51BCC0;
 
39
}
 
40
 
 
41
DEFINE_HOOK(51DF8C, InfantryClass_Fire_RearmTimer, 6)
 
42
{
 
43
        GET(InfantryClass *, I, ESI);
 
44
        int Ammo = I->Type->Ammo;
 
45
        if(Ammo > 0 && I->Ammo < Ammo) {
 
46
                I->ReloadNow();
 
47
        }
 
48
        return 0;
 
49
}
 
50
 
 
51
DEFINE_HOOK(6FF66C, TechnoClass_Fire_RearmTimer, 6)
 
52
{
 
53
        GET(TechnoClass *, T, ESI);
 
54
        if(BuildingClass * B = specific_cast<BuildingClass *>(T)) {
 
55
                int Ammo = B->Type->Ammo;
 
56
                if(Ammo > 0 && B->Ammo < Ammo) {
 
57
                        B->ReloadNow();
 
58
                }
 
59
        }
 
60
        return 0;
 
61
}
 
62