Permalink
Browse files

Fixed bg_get_data script command (#3921)

* In some cases the command didn't return the members ID for 'type 1'
  • Loading branch information...
Atemo committed Feb 7, 2019
1 parent 5908c04 commit 747781fb89092f3d9e4bf9a5edc8ab458fb23564
Showing with 19 additions and 18 deletions.
  1. +19 −18 src/map/script.cpp

BUILDIN_FUNC(bg_get_data)
{
struct battleground_data *bg;
int bg_id = script_getnum(st,2),
type = script_getnum(st,3), i;
struct battleground_data *bg = bg_team_search( script_getnum(st, 2) );

if( (bg = bg_team_search(bg_id)) == NULL )
{
script_pushint(st,0);
if (bg == NULL) {
script_pushint(st, 0);
return SCRIPT_CMD_SUCCESS;
}
int i, j, type = script_getnum(st, 3);

switch( type )
{
case 0: script_pushint(st, bg->count); break;
case 1:
for (i = 0; bg->members[i].sd != NULL; i++)
mapreg_setreg(reference_uid(add_str("$@arenamembers"), i), bg->members[i].sd->bl.id);
mapreg_setreg(add_str("$@arenamemberscount"), i);
script_pushint(st, i);
break;
default:
ShowError("script:bg_get_data: unknown data identifier %d\n", type);
break;
switch( type ) {
case 0:
script_pushint(st, bg->count);
break;
case 1:
for (i = 0, j = 0; i < ARRAYLENGTH(bg->members); i++) {
if (bg->members[i].sd != NULL)
mapreg_setreg(reference_uid(add_str("$@arenamembers"), j++), bg->members[i].sd->bl.id);
}
mapreg_setreg(add_str("$@arenamemberscount"), j);
script_pushint(st, j);
break;
default:
ShowError("script:bg_get_data: unknown data identifier %d\n", type);
break;
}

return SCRIPT_CMD_SUCCESS;

0 comments on commit 747781f

Please sign in to comment.