View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003741 | The Dark Mod | Coding | public | 31.05.2014 20:29 | 27.07.2014 18:44 |
Reporter | SteveL | Assigned To | SteveL | ||
Priority | normal | Severity | normal | Reproducibility | N/A |
Status | resolved | Resolution | fixed | ||
Product Version | TDM 2.02 | ||||
Target Version | TDM 2.03 | Fixed in Version | TDM 2.03 | ||
Summary | 0003741: Some objectives-related script events have inconsistent indexing and bad bounds checks | ||||
Description | Some script events fail to decrement the passed index for objective number. They also have bad bounds checks that would lead them to overwrite the wrong memory if used with the normal 1-based counting system for objectives. Others adjust the index correctly but still have the bad bounds check. Needs checking through thoroughly. | ||||
Additional Information | Forum discussion: http://forums.thedarkmod.com/topic/16249-testing-202/page__view__findpost__p__346801 The affected script events are not yet used in the game or in any published FMs. | ||||
Tags | No tags attached. | ||||
Attached Files | |||||
Ok I completed the audit. Full results attached. First, the rules: 1. Script events and entity targets start counting objectives at 1, to align to DR 2. Game code in c++ starts counting at zero, to align to c++ 3. Code that handles script events should therefore subtract 1 from the number passed by the scripter or the target, before calling an internal function that starts counting at 0 4. c++ code uses the internal function, not the script event handler 5. bounds must be checked correctly Table of results attached, covering the script events, their callers, their calls to internal handlers, the bounds checks in the internal handlers, and the callers of the internal handlers. Also checked that objective and component numbers are handled ok in the rest of the module. The good news is that there's no calling code anywhere else in the codebase that needs changing. Likewise no published maps. All entity targets are using the indexes ok. Changes can be restricted to the script events in player.cpp and the handlers in MissionData.cpp. 5 script events pass a bad parameter, and 7 internal handlers have bad bounds checks. In addition to that, one script event (Event_SetObjectiveComp) uses a non-standard setup. It looks like an earlier design before the current convention was established. It's not broken but it breaks rules 2, 3, and 4 by using an intermediate handler that does the index subtraction and the bounds check. And that intermediate is called from one other place in the c++ code (Target_SetObjectiveComponentState), which is the only place in the c++ code that passes a 1-based index and isn't a bug. Comparable entities like Ctarget_SetObjectiveState follow the usual 0-based rules. Given there are no callers of the intermediate except for that target and the script event, I suggest we eliminate it and move the bounds check to the internal handler, then everything will work the same way. All the rest of the internal handlers have bounds checks, again this one is an odd one out. |
|
Fixed at rev 6075. Updated file attached. |
|
Date Modified | Username | Field | Change |
---|---|---|---|
31.05.2014 20:29 | SteveL | New Issue | |
31.05.2014 20:29 | SteveL | Status | new => assigned |
31.05.2014 20:29 | SteveL | Assigned To | => SteveL |
31.05.2014 20:29 | SteveL | Additional Information Updated | |
01.06.2014 10:05 | SteveL | Severity | crash => normal |
11.06.2014 18:14 | SteveL | File Added: objective script events.ods | |
11.06.2014 18:16 | SteveL | Note Added: 0006670 | |
11.06.2014 18:19 | SteveL | Note Edited: 0006670 | |
11.06.2014 18:26 | SteveL | Note Edited: 0006670 | |
27.07.2014 18:37 | SteveL | File Deleted: objective script events.ods | |
27.07.2014 18:37 | SteveL | File Added: objective script events.ods | |
27.07.2014 18:43 | SteveL | Note Added: 0006811 | |
27.07.2014 18:43 | SteveL | Note Edited: 0006811 | |
27.07.2014 18:44 | SteveL | Status | assigned => resolved |
27.07.2014 18:44 | SteveL | Fixed in Version | => TDM 2.03 |
27.07.2014 18:44 | SteveL | Resolution | open => fixed |