Forum Archive

Go Back   3D Realms Forums > 3D Realms Topics > Other Apogee/3D Realms Games > Rise of the Triad (1995) Source Code
Blogs FAQ Community Calendar

Notices

 
 
Thread Tools
Old 08-04-2004, 04:19 AM   #1
jdaniel
Guest
Static objects and ETOUCH
I'm currently trying to get a grasp of the ROTT source and noticed a strange array subscript in the original source.

RT_ACTOR.H:44: #define MAXTOUCH 10
RT_ACTOR.H:283: _2Dpoint ETOUCH[MAXTOUCH];
This results in an array of 10 _2Dpoint elements with indices 0 to 9.

tempstat is of type statobj_t and the struct member linked_to is of type int because the linked object might be another statobj_t or an objtype or something else. This only works on platforms where sizeof(int) equals the size of a pointer. Ok so far nothing special.

In RT_STAT.C a pointer to an statobj_t LASTSTAT gets declared.
RT_STAT.C:63: statobj_t *LASTSTAT

The function void ExplodeStatic(statobj_t*tempstat) contains a line like this:
RT_ACTOR.C:10844: tempstat->linked_to = (int)(LASTSTAT);
This casts LASTSTAT to int resulting in the address of the statobj_t pointed to by LASTSTAT. This address is now stored in tempstat->linked_to.

In void DamageStaticObject(statobj_t*tempstat,int damage) there is a switch case statement
Code:
switch (tempstat->itemnumber)
{
      case stat_dariantouch:
            MISCVARS->ETOUCH[tempstat->linked_to].x = MISCVARS->ETOUCH[tempstat->linked_to].y = 0;
tempstat->linked_to is used as an array subscript or index into the ETOUCH array but the value of linked_to most likely is greater than 9. So either I've missed some magic somewhere in the code or this may result in a segfault or overwrite other memory of rott.
I'm not sure what kind of information is stored in the ETOUCH array.
Maybe it's some kind of touch position.
If anyone knows about this please help me out.

Jon Daniel
 
 

Bookmarks

Tags
rott, static objects


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 07:17 PM.

Page generated in 0.07517099 seconds (100.00% PHP - 0% MySQL) with 18 queries

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

Website is ©1987-2014 Apogee Software, Ltd.
Ideas and messages posted here become property of Apogee Software Ltd.