Browse Source

clean and format portal.cpp

pull/25/head
Andrew Dunstan 8 years ago committed by Anders Jenbo
parent
commit
0a17c0961d
  1. 91
      Source/portal.cpp
  2. 7
      Source/portal.h
  3. 4
      structs.h

91
Source/portal.cpp

@ -10,16 +10,16 @@ int WarpDropY[MAXPORTAL] = { 40, 40, 40, 40 };
void __cdecl InitPortals() void __cdecl InitPortals()
{ {
int i; // edi int i;
for(i = 0; i < MAXPORTAL; i++) for(i = 0; i < MAXPORTAL; i++)
{ {
if(delta_portal_inited(i)) if(delta_portal_inited(i))
portal[i].open = 0; portal[i].open = FALSE;
} }
} }
void __fastcall SetPortalStats(int i, int o, int x, int y, int lvl, int lvltype) void __fastcall SetPortalStats(int i, BOOL o, int x, int y, int lvl, int lvltype)
{ {
portal[i].x = x; portal[i].x = x;
portal[i].setlvl = 0; portal[i].setlvl = 0;
@ -31,7 +31,7 @@ void __fastcall SetPortalStats(int i, int o, int x, int y, int lvl, int lvltype)
void __fastcall AddWarpMissile(int i, int x, int y) void __fastcall AddWarpMissile(int i, int x, int y)
{ {
int mi; // eax int mi;
missiledata[MIS_TOWN].mlSFX = -1; missiledata[MIS_TOWN].mlSFX = -1;
dMissile[x][y] = 0; dMissile[x][y] = 0;
@ -50,74 +50,61 @@ void __fastcall AddWarpMissile(int i, int x, int y)
void __cdecl SyncPortals() void __cdecl SyncPortals()
{ {
int v0; // edi int i;
int *v1; // esi
int v2; // eax for (i = 0; i < MAXPORTAL; i++) {
if (!portal[i].open)
v0 = 0; continue;
v1 = &portal[0].level; if (!currlevel)
do AddWarpMissile(i, WarpDropX[i], WarpDropY[i]);
{ else {
if ( *(v1 - 3) ) int lvl = currlevel;
{ if (setlevel)
if ( currlevel ) lvl = (unsigned char)setlvlnum;
{ if (portal[i].level == lvl)
v2 = currlevel; AddWarpMissile(i, portal[i].x, portal[i].y);
if ( setlevel )
v2 = (unsigned char)setlvlnum;
if ( *v1 == v2 )
AddWarpMissile(v0, *(v1 - 2), *(v1 - 1));
}
else
{
AddWarpMissile(v0, WarpDropX[v0], WarpDropY[v0]);
}
} }
v1 += 6;
++v0;
} }
while ( (signed int)v1 < (signed int)&portal[MAXPORTAL].level );
} }
// 5CCB10: using guessed type char setlvlnum; // 5CCB10: using guessed type char setlvlnum;
// 5CF31D: using guessed type char setlevel; // 5CF31D: using guessed type char setlevel;
// 69BD04: using guessed type int questlog;
void __fastcall AddInTownPortal(int i) void __fastcall AddInTownPortal(int i)
{ {
AddWarpMissile(i, WarpDropX[i], WarpDropY[i]); AddWarpMissile(i, WarpDropX[i], WarpDropY[i]);
} }
void __fastcall ActivatePortal(int i, int x, int y, int lvl, int lvltype, int sp) void __fastcall ActivatePortal(int i, int x, int y, int lvl, int lvltype, BOOL sp)
{ {
portal[i].open = 1; portal[i].open = TRUE;
if ( lvl ) if ( lvl )
{ {
portal[i].level = lvl;
portal[i].x = x; portal[i].x = x;
portal[i].ltype = lvltype;
portal[i].y = y; portal[i].y = y;
portal[i].level = lvl;
portal[i].ltype = lvltype;
portal[i].setlvl = sp; portal[i].setlvl = sp;
} }
} }
void __fastcall DeactivatePortal(int i) void __fastcall DeactivatePortal(int i)
{ {
portal[i].open = 0; portal[i].open = FALSE;
} }
bool __fastcall PortalOnLevel(int i) BOOL __fastcall PortalOnLevel(int i)
{ {
if ( portal[i].level == currlevel ) if ( portal[i].level == currlevel )
return 1; return TRUE;
else else
return currlevel == 0; return currlevel == 0;
} }
void __fastcall RemovePortalMissile(int id) void __fastcall RemovePortalMissile(int id)
{ {
int i; // esi int i;
int mi; // eax int mi;
for ( i = 0; i < nummissiles; ++i ) for ( i = 0; i < nummissiles; ++i )
{ {
@ -178,7 +165,12 @@ void __cdecl GetPortalLevel()
void __cdecl GetPortalLvlPos() void __cdecl GetPortalLvlPos()
{ {
if ( currlevel ) if ( !currlevel )
{
ViewX = WarpDropX[portalindex] + 1;
ViewY = WarpDropY[portalindex] + 1;
}
else
{ {
ViewX = portal[portalindex].x; ViewX = portal[portalindex].x;
ViewY = portal[portalindex].y; ViewY = portal[portalindex].y;
@ -189,24 +181,15 @@ void __cdecl GetPortalLvlPos()
ViewY++; ViewY++;
} }
} }
else
{
ViewX = WarpDropX[portalindex] + 1;
ViewY = WarpDropY[portalindex] + 1;
}
} }
BOOL __fastcall PosOkPortal(int lvl, int x, int y) BOOL __fastcall PosOkPortal(int lvl, int x, int y)
{ {
int *v3; // eax int i;
v3 = &portal[0].x; for (i = 0; i < MAXPORTAL; i++) {
while ( !*(v3 - 1) || v3[2] != lvl || (*v3 != x || v3[1] != y) && (*v3 != x - 1 || v3[1] != y - 1) ) if (portal[i].open && portal[i].level == lvl && ((portal[i].x == x && portal[i].y == y) || (portal[i].x == x - 1 && portal[i].y == y - 1)))
{ return TRUE;
v3 += 6;
if ( (signed int)v3 >= (signed int)&portal[MAXPORTAL].x )
return 0;
} }
return 1; return FALSE;
} }
// 69BCFC: using guessed type int END_portalstruct;

7
Source/portal.h

@ -4,16 +4,15 @@
extern PortalStruct portal[MAXPORTAL]; extern PortalStruct portal[MAXPORTAL];
extern int portalindex; extern int portalindex;
// int END_portalstruct; // weak
void __cdecl InitPortals(); void __cdecl InitPortals();
void __fastcall SetPortalStats(int i, int o, int x, int y, int lvl, int lvltype); void __fastcall SetPortalStats(int i, BOOL o, int x, int y, int lvl, int lvltype);
void __fastcall AddWarpMissile(int i, int x, int y); void __fastcall AddWarpMissile(int i, int x, int y);
void __cdecl SyncPortals(); void __cdecl SyncPortals();
void __fastcall AddInTownPortal(int i); void __fastcall AddInTownPortal(int i);
void __fastcall ActivatePortal(int i, int x, int y, int lvl, int lvltype, int sp); void __fastcall ActivatePortal(int i, int x, int y, int lvl, int lvltype, BOOL sp);
void __fastcall DeactivatePortal(int i); void __fastcall DeactivatePortal(int i);
bool __fastcall PortalOnLevel(int i); BOOL __fastcall PortalOnLevel(int i);
void __fastcall RemovePortalMissile(int id); void __fastcall RemovePortalMissile(int id);
void __fastcall SetCurrentPortal(int p); void __fastcall SetCurrentPortal(int p);
void __cdecl GetPortalLevel(); void __cdecl GetPortalLevel();

4
structs.h

@ -683,12 +683,12 @@ struct ObjectStruct {
////////////////////////////////////////////////// //////////////////////////////////////////////////
struct PortalStruct { struct PortalStruct {
int open; BOOL open;
int x; int x;
int y; int y;
int level; int level;
int ltype; int ltype;
int setlvl; BOOL setlvl;
}; };
////////////////////////////////////////////////// //////////////////////////////////////////////////

Loading…
Cancel
Save