Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

LUA AddReloadsToUnit remove option off-by-one bug

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Air / Naval Operations >> Tech Support >> LUA AddReloadsToUnit remove option off-by-one bug Page: [1]
Login
Message << Older Topic   Newer Topic >>
LUA AddReloadsToUnit remove option off-by-one bug - 2/18/2019 3:54:59 PM   
KnightHawk75

 

Posts: 112
Joined: 11/15/2018
Status: offline
Build: v1.14 998.17 (applies back to at least 1.14 998.15 as well)

When using the ScenEdit_AddReloadsToUnit() function's remove=true + number=number option to subtract an item,
AND
The mount in question has more than one entry for the wpn_dbid involved it seems to have a an off by one error upon reaching the next weapon entry of same while doing subtraction\removals. It's cumulative, the more of the same wpn_dbid it iterates though for the subtraction on the mount the more off it gets (by one each time).

The following code helps illustrate the problem, cut and paste it the editor.
1. Run as is. Check out the s-400 site's weapons in the editor,it removed 3 as expected. Then delete or move unit.
2. Now comment out the testme(3) line and un-comment out test(5) and run it.
3. Note it removed 6 sa-21b's not 5 .

[see attached textfile script forum was screwing with code due to italics [ i ] issue]

You can change the code to duplicate the updateunit call (making 12 missiles each) and add a Testme(10) and it will demonstrate off-by-2 as that will result in a -12 result, and so on.


Attachment (1)

< Message edited by KnightHawk75 -- 2/18/2019 4:02:15 PM >
Post #: 1
RE: LUA AddReloadsToUnit remove option off-by-one bug - 2/19/2019 8:10:49 AM   
michaelm75au


Posts: 12278
Joined: 5/5/2001
From: Sydney, Australia
Status: offline
I'll check it out

_____________________________

Michael

(in reply to KnightHawk75)
Post #: 2
RE: LUA AddReloadsToUnit remove option off-by-one bug - 2/19/2019 12:27:30 PM   
KnightHawk75

 

Posts: 112
Joined: 11/15/2018
Status: offline
Thanks Michael, appreciate you looking into it.


(in reply to michaelm75au)
Post #: 3
RE: LUA AddReloadsToUnit remove option off-by-one bug - 2/20/2019 7:11:17 AM   
michaelm75au


Posts: 12278
Joined: 5/5/2001
From: Sydney, Australia
Status: offline
Yea, removing loop was doing a 'x > y' rather than a 'x >= y' to cater for last item in the load

_____________________________

Michael

(in reply to KnightHawk75)
Post #: 4
RE: LUA AddReloadsToUnit remove option off-by-one bug - 2/20/2019 1:25:46 PM   
KnightHawk75

 

Posts: 112
Joined: 11/15/2018
Status: offline
Cool. Figured it was something simple like that but also equally easy to go unnoticed.

(in reply to michaelm75au)
Post #: 5
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Air / Naval Operations >> Tech Support >> LUA AddReloadsToUnit remove option off-by-one bug Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.115