mapreg->setreg question

andybe

New member
Messages
13
Points
0
Github
germanafro
hi, I'm currently reviewing battleground.c

but I'm stuck at this part of the code.

for (i = 0; i < VECTOR_LENGTH(queue->entries); i++) {
struct map_session_data *sd = map->id2sd(VECTOR_INDEX(queue->entries, i));

if (sd == NULL || sd->bg_queue.ready != 1)
continue;
int uid = reference_uid(script->add_str("$@bg_member"), count);
#ifdef TRACE
ShowXilero("BG begin uid $@bg_member %d\n", uid);
#endif

mapreg->setreg(uid, sd->status.account_id);
mapreg->setreg(reference_uid(script->add_str("$@bg_member_group"), count),
sd->bg_queue.type == BGQT_GUILD ? sd->status.guild_id :
sd->bg_queue.type == BGQT_PARTY ? sd->status.party_id :
0
);
mapreg->setreg(reference_uid(script->add_str("$@bg_member_type"), count),
sd->bg_queue.type == BGQT_GUILD ? 1 :
sd->bg_queue.type == BGQT_PARTY ? 2 :
0
);
count++;
}
mapreg->setreg(script->add_str("$@bg_member_size"),count);




particularly

mapreg->setreg(reference_uid(script->add_str("$@bg_member"), count), sd->status.account_id);

i pieced that up to debug what is happening.

I noticed that they all adress the same variable with the same uid, thus the data is overwriting each other in each loop. SO all the individual playerdata is lost. It feels to me like that is not intentional and neither going to work out well.

I placed this in scripting topic as using mapreg is obviously relevant to scripting.

This directly leads to the question how to best adress to that variable in script. Is there a way to create an array with mapreg->setreg? that way we can iterate through the arrays and process the data accordingly for each member of the queue

thanks if anyone can clear that up for me

 
It's not getting overwritten; reference_uid() is var, index. In this case "count" is the index, and it's being incremented every time (count++).

To iterate through those variables in script, a simple for() loop will do the trick just fine. See also:




 
Last edited by a moderator:
I see - I might be running a little off topic but how come uid turns out the same for different count values in my debug screen?

cause I forgot to declare it as int64?

 
Back
Top