Jump to content
  • 0
evilpuncker

clif->ShowScript doubt and retVal question

Question

Hello everyone! thanks for stopping by. I have zero source/programing knowledge but I was able to make this code to work (yes, it works), but there are two things bothering me:

 

  1. the clif->ShowScript part works but its throw a warning when compiling
    the warning is: 
    Quote

    warning C4133: 'function': incompatible types - from 'map_session_data *' to 'block_list *'

  2. the return retVal; that I commented out and changed it to return true;, is it okay? I made these changes to old code following these changes to make the code work on newer hercules

 

(yes I know I can ignore warnings, but maybe its something really easy that I'm missing and can be fixed)

 

 

this is the code:

 

bool filter_chat(struct map_session_data **sd, const char **message_)
{
	const char* message = *message_;

	unsigned int i;
	char output[254]; // Compiler supposed to reuse the pre-allocated space but who knows, those few bytes doesn't worth lowering the speed.

	if (!message)
		return false;

	if (!mannersize || pc_has_permission(*sd, bypass_chat_filter) || !pc->can_talk(*sd))
		//return retVal;
		return true;

	for (i = 0; i < mannersize; ++i) {
		if (libpcre->exec(mannerlist[i].regex, mannerlist[i].extra, message, (int)strlen(message), 0, 0, NULL, 0) != PCRE_ERROR_NOMATCH) {
			sprintf(output, "i've been saying bad stuff");
			clif->messagecolor_self((*sd)->fd, COLOR_RED, output);
			clif->ShowScript(*sd, "watch out for your mouth", AREA);
			hookStop();
			return false;
		}
	}

	return true;
}

 

its part of this plugin (the lite version)

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 1

I guess you have been passing the wrong struct to ShowScript function, use this instead : (as you can see here)

clif->ShowScript(&(*sd)->bl, "your message", AREA);

About deleting that conditional... You shouldn't do it if the original function is not gonna be executed ever, not sure about this specific case, and keep in note that when using preHook your function is gonna be executed first.

Edited by Waken

Share this post


Link to post
Share on other sites
  • 1

Hello there, i'm not an expert but i'm gonna try to help.
1. About your warning, i got zero errors compiling your plugin in linux so i have no idea why it gives you the warning.
2. Since now you are using a preHook, you don't need to use **retVal**. This is only used when it's a postHook, because sometimes you want to know the returned value from the original execution (for example... stop your hook if you need it when returning an error).

Is it your "little version" related to the warning, or there's more code somewhere?

Edited by Waken

Share this post


Link to post
Share on other sites
  • 0
10 minutes ago, Waken said:

Hello there, i'm not an expert but i'm gonna try to help.
1. About your warning, i got zero errors compiling your plugin in linux so i have no idea why it gives you the warning.
2. Since now you are using a preHook, you don't need to use **retVal**. This is only used when it's a postHook, because sometimes you want to know the returned value from the original execution (for example... stop your hook if you need it when returning an error).

Is it your "little version" related to the warning, or there's more code somewhere?

 

thanks! the "full" code is here on this paste (its missing the showScript part thought)

 

so I can just remove these three lines? since now the code is using preHook

if (!mannersize || pc_has_permission(*sd, bypass_chat_filter) || !pc->can_talk(*sd))
//return retVal;
return true;

 

yeah I forgot to say my OS is windows, this is the warning:

Wkgq4pg.png

 

when I click the warning it sends the cursor directly to the *sd part

Edited by evilpuncker

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.