View Issue Details

IDProjectCategoryView StatusLast Update
0003741The Dark ModCodingpublic27.07.2014 18:44
ReporterSteveL Assigned ToSteveL  
PrioritynormalSeveritynormalReproducibilityN/A
Status resolvedResolutionfixed 
Product VersionTDM 2.02 
Target VersionTDM 2.03Fixed in VersionTDM 2.03 
Summary0003741: Some objectives-related script events have inconsistent indexing and bad bounds checks
DescriptionSome 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 InformationForum 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.
TagsNo tags attached.
Attached Files

Activities

SteveL

SteveL

11.06.2014 18:16

reporter   ~0006670

Last edited: 11.06.2014 18:26

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.

SteveL

SteveL

27.07.2014 18:43

reporter   ~0006811

Last edited: 27.07.2014 18:43

Fixed at rev 6075. Updated file attached.

Issue History

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