[Bug] Cannon acting weird

[Bug] Cannon acting weird

Postby StefanP.MUC » 28 Mar 2012, 11:37

Seems with the refactoring also a small bug found its way into the game. Luckily no crasher bug this time. :D The cannon is acting strange.

Problem: The Cannon doesn't rotate anymore and shoots cannonballs into wrong directions and it shoots own creatures. Own creatures do not attack the cannon however.

When did it appear: The bug appeared some commits/days ago already, when generalizing everything into GameEntity. Not sure which commit exactly. Probably when making Trap a GameEntity.

I'd tried to find the cause of this behaviour, but I coulnd't find where the Cannon rotates itself and where I have to look for the code that finds out which objects to attack... I assume that some color comparison goes wrong here.

Maybe the refactoring even "fixed" some other Trap bug/hack that caused this new one to appear, because only the Cannon is acting strange, the fighting code for everything else works fine as always even though everything else was also refactored.
StefanP.MUC
 

Re: [Bug] Cannon acting weird

Postby StefanP.MUC » 28 Mar 2012, 13:42

Just startet moving some stuff from MovablegameEntity into GameEntity. Moving position and the corresponding g/setters and semaphores and removing all uneeded 1:1 re-implmentations from derived objects.

This made the cannonballs fly correctly again: "Sub-Bug" no. 2 solved.

The cannon is still attacking own creatures and not rotating, however.
StefanP.MUC
 

Re: [Bug] Cannon acting weird

Postby oln » 28 Mar 2012, 20:09

Are you sure the cannon was able to rotate? I would assume that would involve using faceToward somewhere.
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [Bug] Cannon acting weird

Postby StefanP.MUC » 28 Mar 2012, 20:18

I thought that I already saw this, but maybe I remember this wrong (maybe I'm mixing this up with Dungeon Keeper in my head :D)... faceToword seems not to be used by Cannon.

Let's assume rotating is currently not implmented, then the attacking bug is still left.
StefanP.MUC
 

Re: [Bug] Cannon acting weird

Postby oln » 28 Mar 2012, 20:38

This is strange, as the cannon is using the same function as creatures to find enemies, and if it got the wrong colour, it should attack the rooms as well. (Is it doing that?)
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Re: [Bug] Cannon acting weird

Postby StefanP.MUC » 29 Mar 2012, 07:34

Not sure, I never saw the cannon destroying rooms. As far as I can see, it's only attacking own creatures.

How long does it take for a cannon to destroy a room? Most creatures die at first hit.


edit: Yes, the cannon also attacks own Buildings. Just took all creatures into my hand, and after a rathr long wait the forge was destroyed.
StefanP.MUC
 

Re: [Bug] Cannon acting weird

Postby Danimal » 29 Mar 2012, 11:38

how do you handle friend or foe selection? Tags or something else?
User avatar
Danimal
OD Moderator
 
Posts: 1407
Joined: 23 Nov 2010, 13:50

Re: [Bug] Cannon acting weird

Postby StefanP.MUC » 29 Mar 2012, 11:55

The objects compare their color with the color from near objects.

Not sure if this is the best way, however (think of allies: different colors, but no-attack contract).

The attack and ownership system should be reworked into a general ownership handling, anyways, IMHO. The color should not be a property of each individual object in the future, but only of the controlling seat/player. The seat/player should have a list of all objects belonging to him, so that all objects automatically have the color of it's owner. And each object only knows it's owner (then objects can just check if they have the same or a friendly owner). This would also make it posible to easily implemenent features that require ownership changes (e.g. trading or claiming of neutral objects): just move the object from one player list to another player list.

But these changes would require a lot of work if no currently working features should be broken, I believe. So maybe this (and other "engine related" changes) should only be started after the inheritance refactoring is done.
StefanP.MUC
 

Re: [Bug] Cannon acting weird

Postby MCMic » 31 Mar 2012, 10:45

Hum, I was involved in the Canon implementation but that was quite some time ago, note sure I'll understand the code better than you :-/
I can assure you I never made the canon rotate ^^
User avatar
MCMic
 
Posts: 723
Joined: 05 Jan 2010, 17:40

Re: [Bug] Cannon acting weird

Postby StefanP.MUC » 31 Mar 2012, 11:35

Ah, ok, thanks for clearing this up. :) Seems I remember this wrongly then.
StefanP.MUC
 

Re: [Bug] Cannon acting weird

Postby paul424 » 10 Apr 2013, 08:07

I get bug on specific IA32 machine , the canon ownership number is wrongly read, and the game segfaults ... no bl**** idea why :
{l Code}: {l Select All Code}
  is >> tempInt;
    t->setControllingSeat(t->getGameMap()->getSeatByColor(tempInt));

On other machine it does not segfault ,,,,

levels_git/Test.level:

{l Code}: {l Select All Code}
# Traps
1  # The number of traps to load.
# meshName   color      NextLine: numTiles      Subsequent Lines: tileX   tileY
Cannon   1
1
-14   -1
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: [Bug] Cannon acting weird

Postby oln » 10 Apr 2013, 10:32

Not sure what could be causing different behaviour, I would guess it tries to get a seat that doesn't exist, which may or may not crash depending on what's in the memory at the specific location.
Why that happens I don't know, but the the player colour value should be checked to be valid before being used in a function that is looking something up using it. From what I remember, there are more places in the map reading code where that should be done.
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Who is online

Users browsing this forum: No registered users and 1 guest