Skip to content

Commit

Permalink
Minor optimizations for the warpguild implementation
Browse files Browse the repository at this point in the history
Follow-up to ebb77e2

Signed-off-by: Haru <haru@dotalux.com>
  • Loading branch information
MishimaHaruna committed Mar 12, 2017
1 parent 386a671 commit 5321ac0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion doc/script_commands.txt
Expand Up @@ -4334,7 +4334,7 @@ SavePointAll: All guild members are warped to their respective save point.
SavePoint: All guild members are warped to the save point of the
currently attached player (will fail if there's no player
attached).

If you specify a from_mapname, warpguild() will only affect those on that map.

Example:
Expand Down
25 changes: 13 additions & 12 deletions src/map/script.c
Expand Up @@ -6680,19 +6680,19 @@ BUILDIN(warpguild)
struct guild* g;
int type;
int i;
int16 map_index = -1;
int16 map_id = -1;

const char *str = script_getstr(st, 2);
int x = script_getnum(st, 3);
int y = script_getnum(st, 4);
int gid = script_getnum(st, 5);

if (script_hasdata(st, 6)) {
map_index = map->mapname2mapid(script_getstr(st, 6));
map_id = map->mapname2mapid(script_getstr(st, 6));
}

g = guild->search(gid);
if(g == NULL)
if (g == NULL)
return true;

type = (strcmp(str, "Random") == 0) ? 0
Expand All @@ -6707,27 +6707,28 @@ BUILDIN(warpguild)

for (i = 0; i < MAX_GUILD; i++) {
if (g->member[i].online && g->member[i].sd != NULL) {
struct map_session_data *pl_sd = g->member[i].sd;

if (map_index >= 0 && map_index != g->member[i].sd->bl.m)
if (map_id >= 0 && map_id != pl_sd->bl.m)
continue;

switch (type)
{
case 0: // Random
if (!map->list[g->member[i].sd->bl.m].flag.nowarp)
pc->randomwarp(g->member[i].sd, CLR_TELEPORT);
if (!map->list[pl_sd->bl.m].flag.nowarp)
pc->randomwarp(pl_sd, CLR_TELEPORT);
break;
case 1: // SavePointAll
if (!map->list[g->member[i].sd->bl.m].flag.noreturn)
pc->setpos(g->member[i].sd, g->member[i].sd->status.save_point.map, g->member[i].sd->status.save_point.x, g->member[i].sd->status.save_point.y, CLR_TELEPORT);
if (!map->list[pl_sd->bl.m].flag.noreturn)
pc->setpos(pl_sd, pl_sd->status.save_point.map, pl_sd->status.save_point.x, pl_sd->status.save_point.y, CLR_TELEPORT);
break;
case 2: // SavePoint
if (!map->list[g->member[i].sd->bl.m].flag.noreturn)
pc->setpos(g->member[i].sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
if (!map->list[pl_sd->bl.m].flag.noreturn)
pc->setpos(pl_sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
break;
case 3: // m,x,y
if (!map->list[g->member[i].sd->bl.m].flag.noreturn && !map->list[g->member[i].sd->bl.m].flag.nowarp)
pc->setpos(g->member[i].sd, script->mapindexname2id(st, str), x, y, CLR_TELEPORT);
if (!map->list[pl_sd->bl.m].flag.noreturn && !map->list[pl_sd->bl.m].flag.nowarp)
pc->setpos(pl_sd, script->mapindexname2id(st, str), x, y, CLR_TELEPORT);
break;
}
}
Expand Down

0 comments on commit 5321ac0

Please sign in to comment.