Skip to content

Commit f3827d5

Browse files
committed
fix: Use byte-strings instead of unicode-strings
1 parent caba681 commit f3827d5

File tree

2 files changed

+58
-56
lines changed

2 files changed

+58
-56
lines changed

src/bindings/callbacks.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include "pysamp/pysamp.h"
66
#include "test/callbackstest.h"
77

8+
#include <stdio.h>
9+
810
char* fromConst(const char * str) {
911
const size_t len = strlen(str);
1012
char * cstr = new char[len + 1];
@@ -39,7 +41,7 @@ PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerCommandText(int playerid,
3941
const char *cmdtext) {
4042
char* cmd = fromConst(cmdtext);
4143
sampgdk::logprintf(cmd);
42-
bool ret = PySAMP::callback("OnPlayerCommandText", Py_BuildValue("(is)", playerid, cmd));
44+
bool ret = PySAMP::callback("OnPlayerCommandText", Py_BuildValue("(iy)", playerid, cmd));
4345
delete[] cmd;
4446
return ret;
4547
}
@@ -62,7 +64,7 @@ PLUGIN_EXPORT bool PLUGIN_CALL OnVehicleDeath(int vehicleid, int killerid) {
6264

6365
PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerText(int playerid, const char * text) {
6466
char* txt = fromConst(text);
65-
bool ret = PySAMP::callback("OnPlayerText", Py_BuildValue("(is)", playerid, txt));
67+
bool ret = PySAMP::callback("OnPlayerText", Py_BuildValue("(iy)", playerid, txt));
6668
delete[] txt;
6769
return ret;
6870
}
@@ -97,7 +99,7 @@ PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerLeaveRaceCheckpoint(int playerid) {
9799

98100
PLUGIN_EXPORT bool PLUGIN_CALL OnRconCommand(const char * cmd) {
99101
char* str = fromConst(cmd);
100-
bool ret = PySAMP::callback("OnPlayerCommandText", Py_BuildValue("(is)", str));
102+
bool ret = PySAMP::callback("OnPlayerCommandText", Py_BuildValue("(iy)", str));
101103
delete[] str;
102104
return ret;
103105
}
@@ -161,7 +163,7 @@ PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerKeyStateChange(int playerid, int newkeys,
161163
PLUGIN_EXPORT bool PLUGIN_CALL OnRconLoginAttempt(const char * ip, const char * password, bool success) {
162164
char* ipStr = fromConst(ip);
163165
char* passwordStr = fromConst(password);
164-
bool ret = PySAMP::callback("OnRconLoginAttempt", Py_BuildValue("(ssO)", ipStr, passwordStr, (success ? Py_True : Py_False)));
166+
bool ret = PySAMP::callback("OnRconLoginAttempt", Py_BuildValue("(yyO)", ipStr, passwordStr, (success ? Py_True : Py_False)));
165167
delete[] ipStr, passwordStr;
166168
return ret;
167169
}
@@ -196,7 +198,7 @@ PLUGIN_EXPORT bool PLUGIN_CALL OnActorStreamOut(int actorid, int forplayerid) {
196198

197199
PLUGIN_EXPORT bool PLUGIN_CALL OnDialogResponse(int playerid, int dialogid, int response, int listitem, const char * inputtext) {
198200
char* inputtextStr = fromConst(inputtext);
199-
bool ret = PySAMP::callback("OnDialogResponse", Py_BuildValue("(iiiis)", playerid, dialogid, response, listitem, inputtextStr));
201+
bool ret = PySAMP::callback("OnDialogResponse", Py_BuildValue("(iiiiy)", playerid, dialogid, response, listitem, inputtextStr));
200202
delete[] inputtextStr;
201203
return ret;
202204
}
@@ -228,7 +230,7 @@ PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerClickPlayerTextDraw(int playerid, int pla
228230
PLUGIN_EXPORT bool PLUGIN_CALL OnIncomingConnection(int playerid, const char * ip_address, int port) {
229231
sampgdk::logprintf("OnIncomingConnection");
230232
char * ipStr = fromConst(ip_address);
231-
bool ret = PySAMP::callback("OnIncomingConnection", Py_BuildValue("(isi)", playerid, ipStr, port));
233+
bool ret = PySAMP::callback("OnIncomingConnection", Py_BuildValue("(iyi)", playerid, ipStr, port));
232234
delete[] ipStr;
233235
return ret;
234236
}

0 commit comments

Comments
 (0)