evilpuncker
vai se tratar garota
- Messages
- 2,178
- Points
- 0
- Age
- 109
- Location
- bronzil
- Github
- EPuncker
- Emulator
- Client Version
- 2019-05-30a MAIN
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:
(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.regex, mannerlist.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)
- the clif->ShowScript part works but its throw a warning when compiling
the warning is:
warning C4133: 'function': incompatible types - from 'map_session_data *' to 'block_list *' - 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.regex, mannerlist.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)