Function return stuff

The best and quickest support by a group of top-notch editing specialists, guaranteed!

Moderator: Forum Guards

Function return stuff

Postby Cozmo » Wed Aug 24, 11 1:40 pm

This stems from the other thread, but warrants its own topic imo because it's a specific problem (for archival reasons I guess).

Trying to access variables from within a struct that's too big to do it directly, so having to use a function. It compiles fine, but I'm not too sure it's actually working. I'd use a debug to find out, but it'd have to be after the return, so would do nothing. Can anyone see anything wrong with this? Thanks in advance.

I'll post the entire mod code next time, if that helps.

Trying to set an int inside an array inside a struct, with MPCS being the other class:
Code: Select all
MPCS.SetCondition(talkingto, MissionNumber, Interactions[MPCS.GetMissionCondition(TalkingTo, MissionNumber)].E_SetMissionCondition);


Function from the other class (MPCS) ... (paranoid the return; actually stops it - not too sure how it works)
Code: Select all
struct Storagez
{
   Var DeusExPlayer DXP;
   var int Condition[40];
};
var() localized Storagez StoredVars[40];

...

function SetCondition(DeusExPlayer DEP, int MissionNumbah, int ChangeTo)
{
   local int i;

   for (i=1; i<40; i++)
   {
      if(StoredVars[i].DXP == DEP)
      {
         StoredVars[i].Condition[MissionNumbah] = ChangeTo; //not sure this is being set
      }
   }
}
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby EXetoC » Tue Nov 22, 11 1:03 am

I'm not sure what you mean by having to do debug stuff after the function returns. The array element should be set, and you can verify this by inserting this just after the assignment in the if-statement
Code: Select all
assert(StoredVars[i].Condition[MissionNumbah] == ChangeTo);


You should also replace this
Code: Select all
i=1; i<40; i++

With this
Code: Select all
i=1; i <ArrayCount(StoredVars); i++

So that you don't have to change it every time you decide to change the size of the array, thus preventing potential bugs from appearing.
Last edited by EXetoC on Tue Nov 22, 11 1:15 am, edited 3 times in total.
EXetoC
Newbie
 
Posts: 20
Joined: Sun Oct 23, 11 12:29 am
Location: Stockholm, Sweden


Return to Editing issues

Who is online

Users browsing this forum: Google [Bot] and 18 guests
cron