jdaniel
08-04-2004, 05:19 AM
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
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
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
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