summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhemagx <ibrahem.h.basyone@gmail.com>2016-09-11 16:56:53 +0200
committerhemagx <ibrahem.h.basyone@gmail.com>2016-09-11 16:56:53 +0200
commitb0850ec37591b1316b1692ad9a3ed4940ad19f7c (patch)
tree7b6bf06e3c256f5a1eb577a807d19b9d01cca397 /src
parent2e50931a0efd4620ff45b0d43d7ef336f077d27d (diff)
parentb437c7382e6d0ca1339427ddbc3e20ca3c6cdf57 (diff)
downloadhercules-b0850ec37591b1316b1692ad9a3ed4940ad19f7c.tar.gz
hercules-b0850ec37591b1316b1692ad9a3ed4940ad19f7c.tar.bz2
hercules-b0850ec37591b1316b1692ad9a3ed4940ad19f7c.tar.xz
hercules-b0850ec37591b1316b1692ad9a3ed4940ad19f7c.zip
Merge pull request #1423 from Ridley8819/nightmare
Closes #1423 as merged
Diffstat (limited to 'src')
-rw-r--r--src/map/script.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 7db3736e3..2633c1e5f 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -2970,17 +2970,18 @@ const void *get_val2(struct script_state *st, int64 uid, struct reg_db *ref)
**/
void script_array_ensure_zero(struct script_state *st, struct map_session_data *sd, int64 uid, struct reg_db *ref) {
const char *name = script->get_str(script_getvarid(uid));
- // is here st can be null pointer and st->rid is wrong?
- struct reg_db *src;
+ struct reg_db *src = NULL;
bool insert = false;
- nullpo_retv(st);
- src = script->array_src(st, sd ? sd : st->rid ? map->id2sd(st->rid) : NULL, name, ref);
-
- if (sd && !st) {
- /* when sd comes, st isn't available */
+ if (st == NULL) {
+ // Special case with no st available, only sd
+ nullpo_retv(sd);
+ src = script->array_src(NULL, sd, name, ref);
insert = true;
} else {
+ if (sd == NULL && st->rid != 0)
+ sd = map->id2sd(st->rid); // Retrieve the missing sd
+ src = script->array_src(st, sd, name, ref);
if( is_string_variable(name) ) {
const char *str = script->get_val2(st, uid, ref);
if (str != NULL && *str != '\0')
@@ -3121,10 +3122,12 @@ struct reg_db *script_array_src(struct script_state *st, struct map_session_data
src = &mapreg->regs;
break;
case '.':/* npc/script */
- if( ref )
+ if (ref != NULL) {
src = ref;
- else
+ } else {
+ nullpo_retr(NULL, st);
src = (name[1] == '@') ? &st->stack->scope : &st->script->local;
+ }
break;
case '\'':/* instance */
nullpo_retr(NULL, st);
@@ -9490,7 +9493,7 @@ BUILDIN(guildskill) {
skill_id = ( script_isstringtype(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
level = script_getnum(st,3);
- if (skill_id < GD_SKILLBASE || skill_id > GD_MAX)
+ if (skill_id < GD_SKILLBASE || skill_id >= GD_MAX)
return true; // not guild skill
id = skill_id - GD_SKILLBASE;