1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/testsuite/fakenative1.sp Sun Mar 30 07:00:22 2008 +0000
1.3 @@ -0,0 +1,85 @@
1.4 +#include <sourcemod>
1.5 +
1.6 +public Plugin:myinfo =
1.7 +{
1.8 + name = "FakeNative Testing Lab #1",
1.9 + author = "AlliedModders LLC",
1.10 + description = "Test suite #1 for dynamic natives",
1.11 + version = "1.0.0.0",
1.12 + url = "http://www.sourcemod.net/"
1.13 +};
1.14 +
1.15 +public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max)
1.16 +{
1.17 + CreateNative("TestNative1", __TestNative1);
1.18 + CreateNative("TestNative2", __TestNative2);
1.19 + CreateNative("TestNative3", __TestNative3);
1.20 + CreateNative("TestNative4", __TestNative4);
1.21 + CreateNative("TestNative5", __TestNative5);
1.22 + return true;
1.23 +}
1.24 +
1.25 +public __TestNative1(Handle:plugin, numParams)
1.26 +{
1.27 + PrintToServer("TestNative1: Plugin: %x params: %d", plugin, numParams);
1.28 + if (numParams == 4)
1.29 + {
1.30 + ThrowNativeError(SP_ERROR_NATIVE, "Four parameters ARE NOT ALLOWED lol");
1.31 + }
1.32 + return 5;
1.33 +}
1.34 +
1.35 +public __TestNative2(Handle:plugin, numParams)
1.36 +{
1.37 + new String:buffer[512];
1.38 + new bytes;
1.39 +
1.40 + GetNativeString(1, buffer, sizeof(buffer), bytes);
1.41 +
1.42 + for (new i=0; i<bytes; i++)
1.43 + {
1.44 + buffer[i] = buffer[i] + 1;
1.45 + }
1.46 +
1.47 + SetNativeString(1, buffer, bytes+1);
1.48 +}
1.49 +
1.50 +public __TestNative3(Handle:plugin, numParams)
1.51 +{
1.52 + new val1 = GetNativeCell(1);
1.53 + new val2 = GetNativeCellRef(2);
1.54 +
1.55 + SetNativeCellRef(2, val1+val2);
1.56 +}
1.57 +
1.58 +public __TestNative4(Handle:plugin, numParams)
1.59 +{
1.60 + new size = GetNativeCell(3);
1.61 + new local[size];
1.62 +
1.63 + GetNativeArray(1, local, size);
1.64 + SetNativeArray(2, local, size);
1.65 +}
1.66 +
1.67 +public __TestNative5(Handle:plugin, numParams)
1.68 +{
1.69 + new local = GetNativeCell(1);
1.70 +
1.71 + if (local)
1.72 + {
1.73 + FormatNativeString(2, 4, 5, GetNativeCell(3));
1.74 + } else {
1.75 + new len = GetNativeCell(3);
1.76 + new fmt_len;
1.77 + new String:buffer[len];
1.78 +
1.79 + GetNativeStringLength(4, fmt_len);
1.80 +
1.81 + new String:format[fmt_len];
1.82 +
1.83 + GetNativeString(2, buffer, len);
1.84 + GetNativeString(4, format, fmt_len);
1.85 +
1.86 + FormatNativeString(0, 0, 5, len, _, buffer, format);
1.87 + }
1.88 +}