Properly parsing the OTA rand() function

Properly parsing the OTA rand() function

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Properly parsing the OTA rand() function

Post by Dragon45 »

OTA cobs had the rand() function as an accesible script element. You could say sometihng like rand(x,y) and the rand function would return a random number between X and Y inclusive.

After poking around the Spring source, I believe I have found a way to get it working on a single machine; but the problem would come with the simulation going out of sync over the internet if two different seeds were provided for rand. I have a question:

Is the COB handling code synced or unsyned? From talking with jounonmiko, it appears tobe unsynced, but i wantd to ask here jsut to be sure.

if it is synced, it will be easy enough to use the CGlobalStuff's rand Int generator to generate a random integer and do some basic arithmetic to get it within the inclusive value as specified in the rand function's parameter list. If not, I would have to try and go with so more hacky approach.
SJ
Posts: 618
Joined: 13 Aug 2004, 17:13

Post by SJ »

COB stuff should be synced.
Jonny C
Posts: 94
Joined: 31 May 2005, 18:06

Post by Jonny C »

Whats a COB ? :p
lol,

Jonny C
User avatar
RightField
Posts: 110
Joined: 11 Nov 2004, 21:29

Post by RightField »

A compiled TA script .BOS file.
Fnordia
Former Engine Dev
Posts: 425
Joined: 13 Aug 2004, 16:11

Post by Fnordia »

Hm.. so what is wrong with the current implementation?
User avatar
Dragon45
Posts: 2883
Joined: 16 Aug 2004, 04:36

Post by Dragon45 »

It doesnt actually do anything with the rand function. I couldnt find any mention of the function in the COB handler source files and such, and its easily visible in the actions of units that use the rand(x,y) function; it jsut doesnt work.
Post Reply

Return to “Engine”