Update CS:GO team score gamedata.
1 // vim: set ts=4 sw=4 tw=99 noet:
6 #include "x86/jit_x86.h"
8 #include "BaseRuntime.h"
9 #include "sp_vm_engine.h"
10 #include "watchdog_timer.h"
11 #include <sourcemod_version.h>
13 using namespace SourcePawn;
15 SourcePawnEngine2::SourcePawnEngine2()
21 IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file, int *err)
27 BaseRuntime *pRuntime;
29 FILE *fp = fopen(file, "rb");
33 error = SP_ERROR_NOT_FOUND;
37 /* Rewind for safety */
38 fread(&hdr, sizeof(sp_file_hdr_t), 1, fp);
40 if (hdr.magic != SPFILE_MAGIC)
42 error = SP_ERROR_FILE_FORMAT;
46 switch (hdr.compression)
48 case SPFILE_COMPRESSION_GZ:
50 uint32_t uncompsize = hdr.imagesize - hdr.dataoffs;
51 uint32_t compsize = hdr.disksize - hdr.dataoffs;
52 uint32_t sectsize = hdr.dataoffs - sizeof(sp_file_hdr_t);
53 uLongf destlen = uncompsize;
55 char *tempbuf = (char *)malloc(compsize);
56 void *uncompdata = malloc(uncompsize);
57 void *sectheader = malloc(sectsize);
59 fread(sectheader, sectsize, 1, fp);
60 fread(tempbuf, compsize, 1, fp);
62 z_result = uncompress((Bytef *)uncompdata, &destlen, (Bytef *)tempbuf, compsize);
68 error = SP_ERROR_DECOMPRESSOR;
72 base = (uint8_t *)malloc(hdr.imagesize);
73 memcpy(base, &hdr, sizeof(sp_file_hdr_t));
74 memcpy(base + sizeof(sp_file_hdr_t), sectheader, sectsize);
76 memcpy(base + hdr.dataoffs, uncompdata, uncompsize);
80 case SPFILE_COMPRESSION_NONE:
82 base = (uint8_t *)malloc(hdr.imagesize);
84 fread(base, hdr.imagesize, 1, fp);
89 error = SP_ERROR_DECOMPRESSOR;
94 pRuntime = new BaseRuntime();
95 if ((error = pRuntime->CreateFromMemory(&hdr, base)) != SP_ERROR_NONE)
104 for (size_t i = len - 1; i < len; i--)
112 pRuntime->SetName(&file[i+1]);
117 if (!pRuntime->plugin()->name)
119 pRuntime->SetName(file);
122 pRuntime->ApplyCompilationOptions(co);
138 SPVM_NATIVE_FUNC SourcePawnEngine2::CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData)
140 return g_Jit.CreateFakeNative(callback, pData);
143 void SourcePawnEngine2::DestroyFakeNative(SPVM_NATIVE_FUNC func)
145 g_Jit.DestroyFakeNative(func);
148 const char *SourcePawnEngine2::GetEngineName()
150 return "SourcePawn 1.2, jit-x86";
153 const char *SourcePawnEngine2::GetVersionString()
155 return SOURCEMOD_VERSION;
158 IProfiler *SourcePawnEngine2::GetProfiler()
163 void SourcePawnEngine2::SetProfiler(IProfiler *profiler)
165 m_Profiler = profiler;
168 IDebugListener *SourcePawnEngine2::SetDebugListener(IDebugListener *listener)
170 return g_engine1.SetDebugListener(listener);
173 unsigned int SourcePawnEngine2::GetAPIVersion()
175 return SOURCEPAWN_ENGINE2_API_VERSION;
178 ICompilation *SourcePawnEngine2::StartCompilation()
180 return g_Jit.StartCompilation();
183 const char *SourcePawnEngine2::GetErrorString(int err)
185 return g_engine1.GetErrorString(err);
188 bool SourcePawnEngine2::Initialize()
190 return g_Jit.InitializeJIT();
193 void SourcePawnEngine2::Shutdown()
195 g_WatchdogTimer.Shutdown();
199 IPluginRuntime *SourcePawnEngine2::CreateEmptyRuntime(const char *name, uint32_t memory)
204 rt = new BaseRuntime();
205 if ((err = rt->CreateBlank(memory)) != SP_ERROR_NONE)
211 rt->SetName(name != NULL ? name : "<anonymous>");
213 rt->ApplyCompilationOptions(NULL);
218 bool SourcePawnEngine2::InstallWatchdogTimer(size_t timeout_ms)
220 return g_WatchdogTimer.Initialize(timeout_ms);