CSGO: Fix messages and director shot natives

CS:GO now uses widestrings wchar_t for event strings instead of normal
utf8 ones.
This commit is contained in:
Peace-Maker 2016-07-28 17:01:58 +02:00
parent 737b2ab1d0
commit a628aeb71e
2 changed files with 20 additions and 2 deletions

View File

@ -34,6 +34,12 @@
#include "extension.h" #include "extension.h"
#if SOURCE_ENGINE == SE_CSGO
# define DIRECTOR_NO_TARGET -1
#else
# define DIRECTOR_NO_TARGET 0
#endif
class HLTVDirectorWrapper { class HLTVDirectorWrapper {
public: public:
void SetPVSEntity(int index); void SetPVSEntity(int index);

View File

@ -267,7 +267,13 @@ static cell_t Native_BroadcastScreenMessage(IPluginContext *pContext, const cell
if (!msg) if (!msg)
return 0; return 0;
#if SOURCE_ENGINE == SE_CSGO
wchar_t wBuffer[1024];
V_UTF8ToUnicode(buffer, wBuffer, sizeof(wBuffer));
msg->SetWString("text", wBuffer);
#else
msg->SetString("text", buffer); msg->SetString("text", buffer);
#endif
int ret = 1; int ret = 1;
bool bLocalOnly = params[1] != 0; bool bLocalOnly = params[1] != 0;
@ -323,7 +329,13 @@ static cell_t Native_BroadcastChatMessage(IPluginContext *pContext, const cell_t
if (!msg) if (!msg)
return 0; return 0;
#if SOURCE_ENGINE == SE_CSGO
wchar_t wBuffer[1024];
V_UTF8ToUnicode(buffer, wBuffer, sizeof(wBuffer));
msg->SetWString("text", wBuffer);
#else
msg->SetString("text", buffer); msg->SetString("text", buffer);
#endif
int ret = 1; int ret = 1;
bool bLocalOnly = params[1] != 0; bool bLocalOnly = params[1] != 0;
@ -389,7 +401,7 @@ static cell_t Native_ForceFixedCameraShot(IPluginContext *pContext, const cell_t
shot->SetInt("posz", vPos.z); shot->SetInt("posz", vPos.z);
shot->SetInt("theta", sp_ctof(angle[0])); shot->SetInt("theta", sp_ctof(angle[0]));
shot->SetInt("phi", sp_ctof(angle[1])); shot->SetInt("phi", sp_ctof(angle[1]));
shot->SetInt("target", params[3] ? gamehelpers->ReferenceToIndex(params[3]) : 0); shot->SetInt("target", params[3] ? gamehelpers->ReferenceToIndex(params[3]) : DIRECTOR_NO_TARGET);
shot->SetFloat("fov", sp_ctof(params[4])); shot->SetFloat("fov", sp_ctof(params[4]));
hltvserver->GetHLTVServer()->BroadcastEvent(shot); hltvserver->GetHLTVServer()->BroadcastEvent(shot);
@ -425,7 +437,7 @@ static cell_t Native_ForceChaseCameraShot(IPluginContext *pContext, const cell_t
return 0; return 0;
shot->SetInt("target1", gamehelpers->ReferenceToIndex(params[1])); shot->SetInt("target1", gamehelpers->ReferenceToIndex(params[1]));
shot->SetInt("target2", params[2] ? gamehelpers->ReferenceToIndex(params[2]) : 0); shot->SetInt("target2", params[2] ? gamehelpers->ReferenceToIndex(params[2]) : DIRECTOR_NO_TARGET);
shot->SetInt("distance", params[3]); shot->SetInt("distance", params[3]);
shot->SetInt("phi", params[4]); // hi/low shot->SetInt("phi", params[4]); // hi/low
shot->SetInt("theta", params[5]); // left/right shot->SetInt("theta", params[5]); // left/right