Jump to content
  • 0
Dastgir

What this checks?

Question

int run_func(struct script_state *st){	struct script_data* data;	int i,start_sp,end_sp,func;	end_sp = st->stack->sp;// position after the last argument	for( i = end_sp-1; i > 0 ; --i )		if( st->stack->stack_data[i].type == C_ARG )			break;	if( i == 0 )	{		ShowError("script:run_func: C_ARG not found. please report this!!!n");		st->state = END;		script_reportsrc(st);		return 1;	}	start_sp = i-1;// C_NAME of the command	st->start = start_sp;	st->end = end_sp;	data = &st->stack->stack_data[st->start];	if( data->type == C_NAME && script->str_data[data->u.num].type == C_FUNC )		func = data->u.num;	else	{		ShowError("script:run_func: not a buildin command.n");		script_reportdata(data);		script_reportsrc(st);		st->state = END;		return 1;	}	if( script->config.warn_func_mismatch_argtypes ) {		script_check_buildin_argtype(st, func);	}	if(script->str_data[func].func){		if (!(script->str_data[func].func(st))){ //Report error			script_reportsrc(st);		}	} else {		ShowError("script:run_func: '%s' (id=%d type=%s) has no C function. please report this!!!n", script->get_str(func), func, script_op2name(script->str_data[func].type));		script_reportsrc(st);		st->state = END;	}	// Stack's datum are used when re-running functions [Eoe]	if( st->state == RERUNLINE )		return 0;	script->pop_stack(st, st->start, st->end);	if( st->state == RETFUNC )	{// return from a user-defined function		struct script_retinfo* ri;		int olddefsp = st->stack->defsp;		int nargs;		script->pop_stack(st, st->stack->defsp, st->start);// pop distractions from the stack		if( st->stack->defsp < 1 || st->stack->stack_data[st->stack->defsp-1].type != C_RETINFO )		{			ShowWarning("script:run_func: return without callfunc or callsub!n");			script_reportsrc(st);			st->state = END;			return 1;		}		script->free_vars( st->stack->var_function );		ri = st->stack->stack_data[st->stack->defsp-1].u.ri;		nargs = ri->nargs;		st->pos = ri->pos;		st->script = ri->script;		st->stack->var_function = ri->var_function;		st->stack->defsp = ri->defsp;		memset(ri, 0, sizeof(struct script_retinfo));		script->pop_stack(st, olddefsp-nargs-1, olddefsp);// pop arguments and retinfo		st->state = GOTO;	}	return 0;}

Above is code of run_func()

I want to ask what this checks for

 

 if(script->str_data[func].func){		if (!(script->str_data[func].func(st))){ //Report error			script_reportsrc(st);		}	}  

 

because its the part that goes to script_reportsrc and gives some [Debug]: Source (NPC) Invisible on map

Edited by dastgirpojee

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

 

 

 

 

if(script->str_data[func].func){// <= check if the pointer isn't null        if (!(script->str_data[func].func(st))){ //run the function            script_reportsrc(st);//if the function returns false, dump the errors        }    }

 

 

But with custom script command, it always returns false and dumps the error(but script is executed.).Should custom function return 1?

 

 

the custom script is at fault then. shouldn't return 1 nor 0, its true or false.

Share this post


Link to post
Share on other sites
  • 0
 if(script->str_data[func].func){// <= check if the pointer isn't null        if (!(script->str_data[func].func(st))){ //run the function            script_reportsrc(st);//if the function returns false, dump the errors        }    } 

Share this post


Link to post
Share on other sites
  • 0

 

if(script->str_data[func].func){// <= check if the pointer isn't null        if (!(script->str_data[func].func(st))){ //run the function            script_reportsrc(st);//if the function returns false, dump the errors        }    }

But with custom script command, it always returns false and dumps the error(but script is executed.).Should custom function return 1?

Edited by Dastgir Pojee

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.