#2151: Shots sometimes pass through the ground - bug + fix + patch
------------------------------------------------+---------------------------
        Reporter:  corvusco...@…                |         Type:  bug          
          Status:  new                          |     Priority:  major        
       Milestone:                               |    Component:  Engine: other
         Version:  trunk and 2.3                |     Keywords:               
Operating System:  All/Non-Specific             |   Blocked By:               
        Blocking:                               |  
------------------------------------------------+---------------------------
 Artillery projectiles, missiles and other ordnance often pass right
 through terrain before they strike the target, both on direct and indirect
 (artillery) shots.

 This means that even the steepest canion usually provides no protection
 from enemy artillery strikes. Sometimes when units on top of a hill get
 fired on, missiles hit them through the ground from below.

 While some players use this to their advantage, I consider this a serious
 bug, since the code does attempt to check for projectile//ground
 collissions.

 Unfortunately there has been a flaw in that code, leading to a failure in
 collission detection.

 Patch and savegame for testing are attached

 map.c:
 {{{
 ...
 /* returns true if object is above ground */
 extern BOOL mapObjIsAboveGround( BASE_OBJECT *psObj )
 {
         // min is used to make sure we don't go over array bounds!
         // TODO Using the corner of the map instead doesn't make sense.
 Fix this...
         SDWORD  iZ,
                         tileX = map_coord(psObj->pos.x),
                         tileY = map_coord(psObj->pos.y),
                         tileYOffset1 = (tileY * mapWidth),
                         tileYOffset2 = ((tileY+1) * mapWidth),
                         h1 = psMapTiles[MIN(mapWidth * mapHeight - 1,
 tileYOffset1 + tileX)    ].height,
                         h2 = psMapTiles[MIN(mapWidth * mapHeight - 1,
 tileYOffset1 + tileX + 1)].height,
                         h3 = psMapTiles[MIN(mapWidth * mapHeight - 1,
 tileYOffset2 + tileX)    ].height,
                         h4 = psMapTiles[MIN(mapWidth * mapHeight - 1,
 tileYOffset2 + tileX + 1)].height;

         /* trivial test above */
         if ( (psObj->pos.z > h1) && (psObj->pos.z > h2) &&
                  (psObj->pos.z > h3) && (psObj->pos.z > h4)    )
         {
                 return true;
         }
 ...
 }}}

 must read

 {{{
 h1 = ELEVATION_SCALE * psMapTiles[MIN(mapWidth * mapHeight - 1,
 tileYOffset1 + tileX)    ].height,
 h2 = ELEVATION_SCALE * psMapTiles[MIN(mapWidth * mapHeight - 1,
 tileYOffset1 + tileX + 1)].height,
 h3 = ELEVATION_SCALE * psMapTiles[MIN(mapWidth * mapHeight - 1,
 tileYOffset2 + tileX)    ].height,
 h4 = ELEVATION_SCALE * psMapTiles[MIN(mapWidth * mapHeight - 1,
 tileYOffset2 + tileX + 1)].height;
 }}}


 regards


 [ilf]CorvusCorax

-- 
Ticket URL: <http://developer.wz2100.net/ticket/2151>
Warzone 2100 Trac <http://developer.wz2100.net/>
The Warzone 2100 Project
_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev

Reply via email to