Browse Source

M teleport (#470)

* Correct NetSendCmdGolem()-cl type.
* Correct gbActivePlayers type
* Clean up M_Teleport
* Clean up PutMissile
pull/25/head
Anders Jenbo 8 years ago committed by GitHub
parent
commit
9123d92ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      Source/missiles.cpp
  2. 94
      Source/monster.cpp
  3. 3
      Source/msg.cpp
  4. 2
      Source/msg.h
  5. 5
      Source/multi.cpp
  6. 2
      Source/multi.h

31
Source/missiles.cpp

@ -705,26 +705,19 @@ void __fastcall GetMissileVel(int i, int sx, int sy, int dx, int dy, int v)
void __fastcall PutMissile(int i)
{
int v1; // eax
int v2; // edx
int v3; // esi
int v4; // edx
_BYTE *v5; // edx
v1 = i;
v2 = missile[i]._mix;
v3 = missile[i]._miy;
if (v2 <= 0 || v3 <= 0 || v2 >= MAXDUNX || v3 >= MAXDUNY)
missile[v1]._miDelFlag = 1;
if (!missile[v1]._miDelFlag) {
v4 = v3 + 112 * v2;
dFlags[0][v4] |= DFLAG_MISSILE;
v5 = (unsigned char *)dMissile + v4;
if (*v5)
*v5 = -1;
int x, y;
x = missile[i]._mix;
y = missile[i]._miy;
if (x <= 0 || y <= 0 || x >= MAXDUNX || y >= MAXDUNY)
missile[i]._miDelFlag = 1;
if (!missile[i]._miDelFlag) {
dFlags[x][y] |= DFLAG_MISSILE;
if (dMissile[x][y] == 0)
dMissile[x][y] = i + 1;
else
*v5 = i + 1;
if (missile[v1]._miPreFlag)
dMissile[x][y] = -1;
if (missile[i]._miPreFlag)
MissilePreFlag = 1;
}
}

94
Source/monster.cpp

@ -2941,72 +2941,44 @@ int __fastcall M_DoTalk(int i)
void __fastcall M_Teleport(int i)
{
int v1; // ebx
//int v2; // ST04_4
MonsterStruct *v3; // esi
int v4; // eax
int v6; // edi
int v7; // ebx
int v8; // eax
int v9; // [esp+Ch] [ebp-24h]
int v10; // [esp+10h] [ebp-20h]
int v11; // [esp+14h] [ebp-1Ch]
int v12; // [esp+18h] [ebp-18h]
int v13; // [esp+1Ch] [ebp-14h]
int a1; // [esp+20h] [ebp-10h]
signed int v15; // [esp+24h] [ebp-Ch]
signed int v16; // [esp+28h] [ebp-8h]
signed int v17; // [esp+2Ch] [ebp-4h]
BOOL tren;
MonsterStruct *Monst;
int k, j, x, y, _mx, _my, rx, ry;
v1 = i;
a1 = i;
if ((DWORD)i >= MAXMONSTERS) {
if ((DWORD)i >= MAXMONSTERS)
TermMsg("M_Teleport: Invalid monster %d", i);
//i = v2;
}
v15 = 0;
v3 = &monster[v1];
if (v3->_mmode != MM_STONE) {
v10 = (unsigned char)v3->_menemyx;
v12 = (unsigned char)v3->_menemyy;
v4 = random(100, 2);
v11 = 2 * v4 - 1;
v17 = -1;
v6 = 0; /* v9 */
v13 = 2 * random(100, 2) - 1;
while (!v15) {
v16 = -1;
v7 = v12 - v13;
do {
if (v15)
break;
if (v17 || v16) {
v9 = v7;
v6 = v10 + v11 * v17;
if (v7 >= 0 && v7 < MAXDUNY && v6 >= 0 && v6 < MAXDUNX && v6 != v3->_mx && v7 != v3->_my) {
if (PosOkMonst(a1, v10 + v11 * v17, v7))
v15 = 1;
tren = FALSE;
Monst = &monster[i];
if (Monst->_mmode != MM_STONE) {
_mx = Monst->_menemyx;
_my = Monst->_menemyy;
rx = 2 * random(100, 2) - 1;
ry = 2 * random(100, 2) - 1;
for (j = -1; j <= 1 && !tren; j++) {
for (k = -1; k < 1 && !tren; k++) {
if (j != 0 || k != 0) {
x = _mx + rx * j;
y = _my + ry * k;
if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX && x != Monst->_mx && y != Monst->_my) {
if (PosOkMonst(i, x, y))
tren = TRUE;
}
}
++v16;
v7 += v13;
} while (v16 < 1);
if (++v17 > 1) {
if (!v15)
return;
v1 = a1;
break;
}
v1 = a1;
}
M_ClearSquares(v1);
v8 = v3->_my + 112 * v3->_mx;
v3->_moldx = v6;
dMonster[0][v8] = 0;
v3->_moldy = v9;
dMonster[v6][v9] = v1 + 1;
v3->_mdir = M_GetDir(v1);
M_CheckEFlag(v1);
}
}
if (tren) {
M_ClearSquares(i);
dMonster[Monst->_mx][Monst->_my] = 0;
dMonster[x][y] = i + 1;
Monst->_moldx = x;
Monst->_moldy = y;
Monst->_mdir = M_GetDir(i);
M_CheckEFlag(i);
}
}

3
Source/msg.cpp

@ -812,7 +812,7 @@ void __fastcall NetSendCmd(BOOL bHiPri, BYTE bCmd)
NetSendLoPri((unsigned char *)&cmd, 1u);
}
void __fastcall NetSendCmdGolem(BYTE mx, BYTE my, BYTE dir, BYTE menemy, int hp, int cl)
void __fastcall NetSendCmdGolem(BYTE mx, BYTE my, BYTE dir, BYTE menemy, int hp, BYTE cl)
{
TCmdGolem cmd; // [esp+0h] [ebp-Ch]
@ -2593,7 +2593,6 @@ int __fastcall On_PLAYER_JOINLEVEL(struct TCmdLocParam1 *pCmd, int pnum)
return sizeof(*pCmd);
}
// 67862C: using guessed type char gbActivePlayers;
int __fastcall On_ACTIVATEPORTAL(struct TCmdLocParam3 *pCmd, int pnum)
{

2
Source/msg.h

@ -32,7 +32,7 @@ void __fastcall DeltaAddItem(int ii);
void __cdecl DeltaSaveLevel();
void __cdecl DeltaLoadLevel();
void __fastcall NetSendCmd(BOOL bHiPri, BYTE bCmd);
void __fastcall NetSendCmdGolem(BYTE mx, BYTE my, BYTE dir, BYTE menemy, int hp, int cl);
void __fastcall NetSendCmdGolem(BYTE mx, BYTE my, BYTE dir, BYTE menemy, int hp, BYTE cl);
void __fastcall NetSendCmdLoc(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y);
void __fastcall NetSendCmdLocParam1(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y, WORD wParam1);
void __fastcall NetSendCmdLocParam2(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y, WORD wParam1, WORD wParam2);

5
Source/multi.cpp

@ -12,7 +12,7 @@ char sgbPlayerLeftGameTbl[MAX_PLRS];
int multi_cpp_init_value; // weak
int sgbSentThisCycle; // idb
int dword_678628; // weak
char gbActivePlayers; // weak
BYTE gbActivePlayers; // weak
char gbGameDestroyed; // weak
char sgbSendDeltaTbl[MAX_PLRS];
_gamedata sgGameInitInfo;
@ -321,7 +321,6 @@ void __fastcall multi_player_left_msg(int pnum, int left)
}
}
// 6761B8: using guessed type char gbSomebodyWonGameKludge;
// 67862C: using guessed type char gbActivePlayers;
void __cdecl multi_net_ping()
{
@ -817,7 +816,6 @@ int __fastcall NetInit(int bSinglePlayer, int *pfExitProgram)
}
// 6761B8: using guessed type char gbSomebodyWonGameKludge;
// 678628: using guessed type int dword_678628;
// 67862C: using guessed type char gbActivePlayers;
// 67862D: using guessed type char gbGameDestroyed;
// 678640: using guessed type char byte_678640;
// 679661: using guessed type char sgbTimeout;
@ -1045,4 +1043,3 @@ void __fastcall multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3)
}
}
}
// 67862C: using guessed type char gbActivePlayers;

2
Source/multi.h

@ -12,7 +12,7 @@ extern char sgbPlayerLeftGameTbl[MAX_PLRS];
extern int multi_cpp_init_value; // weak
extern int sgbSentThisCycle; // idb
extern int dword_678628; // weak
extern char gbActivePlayers; // weak
extern BYTE gbActivePlayers;
extern char gbGameDestroyed; // weak
extern char sgbSendDeltaTbl[MAX_PLRS];
extern _gamedata sgGameInitInfo;

Loading…
Cancel
Save