Commit graph

18 commits

Author SHA1 Message Date
Yamagi Burmeister
bc5f569880 Try to fix monsters getting stuck by waiting forever for their enemy.
44472722e added some sanity checks to the AI code. The checks in
ai_run() are likely wrong because the enemy entity might be already
NULL if we arrive their. By aborting early the code is unable to
determine a new enemy or return the monster to idle state, so the
monster will wait forever for an enemy that'll never come.

This happens only in monster vs. monster fights. Never in monster vs.
player, that game ends if the player dies.

In theory this change should be harmless, because if the enemy entity is
gone it won't generate sound targets now be visible. If the game crashes
by self->enemy being NULL we've got a problem elsewere.

This was reported by @BjossiAlfreds in #483. He also suggested the fix.
2019-08-31 11:17:38 +02:00
Yamagi Burmeister
a9b24bfa04 Fix a potential crash in ai_run_melee() and ai_run_missile().
This was found and fixed by Maraakate.
2017-09-07 18:09:25 +02:00
Yamagi Burmeister
80fb945cff Make sure that a monsters enemy is still alive when deciding to attack.
When the monster was already killed by another monster or a coop player
some references may be NULL and the game was crashed. This was observed
by maraakte, who reported it in issue #164. I've just merged his fix
from q2dos.
2016-12-30 10:25:22 +01:00
Yamagi Burmeister
d3f299cca6 Reorder conditionals to please unoptimizing compilers
This was requested by Maraakate. This is likely a noop, since even
early compilers from th 1970th supported simple optimiziations like
this.
2016-12-20 15:21:24 +01:00
Yamagi Burmeister
77536e07d8 Change edict_s->show_hostile from qboolean to int and add casts
This variable is used as an integer. Defining it as a qbooblean is
just wrong. Add some explicit float -> int casts while at it.
2016-12-18 09:17:54 +01:00
Yamagi Burmeister
1bea78c4ec Rename teleport_time to last_sound time
teleport_time has nothing to do with teleports, it's just the time
since the last player sound. Rename it accordingly. This was suggest
by maraakate in yquake2 issue #162.
2016-12-18 09:16:28 +01:00
Yamagi Burmeister
20cdbfe1c0 Fix monsters ignoring the player under certain circumstances
In ai_checkattack() is a check against AI_SOUND_TARGET. If the player
made a noice and the the monster noticed this noise it's true. If
that noice was more than 5 seconds ago the monster forgets that event
and continues with it's search for the player. Otherwise it informs
the surrounding monsters that something interesting has happened and
then returns false. So the problem is: Even if the monster heard the
player and can see him, it aborts at this point.

Fix this by adding an additional visibility check. Do the sound
checking only if the player is not visible, otherwise just continue.

This was reported by shoober420 and debbuged by maraakate. This fix
was DanielGibons idea. This commit fixes yquake2 issue #162.
2016-12-18 09:15:21 +01:00
Daniel Gibson
d1e811bd5b Fix typo in ai_checkattack() leading to monsters running in place
this is the fix from yquake2/#151
2016-10-23 18:28:36 +02:00
Yamagi Burmeister
3bd64f2da0 Remove superflous statement
This was originaly committed into baseq2 by svdijk
2013-04-29 18:20:11 +02:00
Yamagi Burmeister
00f0bb8df1 Remove superfluous whitespaces and end of lines
With this commit 'xatrix' is cleaned up. Every single line was audited,
many bugs removed and hundered of sanity checks added. Additionally the
code was reformated. All in all 'Xatrix' should now be much more
reliable and for the first time in ~15 years completeable without any
crashes, logic bugs or the like. Until now about 130 hours spread over
more than a year were spend for this project.

Of course this code is totaly untested. The next step is testing,
testing and testing. After that the spawn points needs to be fixed
so that all maps can pe started by "map $mapname".
2013-02-12 18:49:17 +01:00
Yamagi Burmeister
848fbea4ce Cleanup g_chase.c and add sanity checks 2011-10-18 08:28:12 +00:00
Yamagi Burmeister
f0a577d6b7 Reformat g_ai.c and add sanity checks 2011-10-18 08:23:19 +00:00
Yamagi Burmeister
62f3b1319f Rearrange files and add a new Makefile 2011-10-11 14:00:27 +00:00
Yamagi Burmeister
eec6f17dff Behebt einen potentiellen Nullpointer beim Herausfinden, ob der Spieler
vor einem Monster steht.
2011-01-23 14:40:50 +00:00
Yamagi Burmeister
7c77178d37 No-Op Änderung, entfernt sinnlosen Code 2010-01-28 16:58:02 +00:00
Yamagi Burmeister
00c3536538 Und das Äufräumen beendet 2009-03-12 19:37:41 +00:00
Yamagi Burmeister
635f0728f8 Fixup, Stufe 1 2009-03-12 17:11:31 +00:00
Yamagi Burmeister
7283829715 Code zu "The Reconing" eingefügCode zu "The Reconing" eingefügt 2009-03-12 16:16:47 +00:00