2008-04-13 08:06:27 +02:00
|
|
|
#include <sourcemod>
|
|
|
|
|
|
|
|
public Plugin:myinfo =
|
|
|
|
{
|
|
|
|
name = "Stack Tests",
|
|
|
|
author = "AlliedModders LLC",
|
|
|
|
description = "Tests stack functions",
|
|
|
|
version = "1.0.0.0",
|
|
|
|
url = "http://www.sourcemod.net/"
|
|
|
|
};
|
|
|
|
|
|
|
|
public OnPluginStart()
|
|
|
|
{
|
|
|
|
RegServerCmd("test_stack", Test_Stack);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action:Test_Stack(args)
|
|
|
|
{
|
2014-11-09 01:56:56 +01:00
|
|
|
int test[20];
|
|
|
|
char buffer[42];
|
2008-04-13 08:06:27 +02:00
|
|
|
|
|
|
|
test[0] = 5
|
|
|
|
test[1] = 7
|
|
|
|
|
2014-11-09 01:56:56 +01:00
|
|
|
ArrayStack stack = ArrayStack(30);
|
|
|
|
stack.Push(50);
|
|
|
|
stack.PushArray(test, 2);
|
|
|
|
stack.PushArray(test, 2);
|
|
|
|
stack.PushString("space craaab");
|
|
|
|
stack.Push(12);
|
2008-04-13 08:06:27 +02:00
|
|
|
|
2014-11-09 01:56:56 +01:00
|
|
|
PrintToServer("empty? %d", stack.Empty);
|
2008-04-13 08:06:27 +02:00
|
|
|
|
2014-11-09 01:56:56 +01:00
|
|
|
stack.Pop();
|
|
|
|
stack.PopString(buffer, sizeof(buffer));
|
2008-04-13 08:06:27 +02:00
|
|
|
PrintToServer("popped: \"%s\"", buffer);
|
|
|
|
test[0] = 0
|
|
|
|
test[1] = 0
|
|
|
|
PrintToServer("values: %d, %d", test[0], test[1]);
|
2014-11-09 01:56:56 +01:00
|
|
|
stack.PopArray(test, 2);
|
2008-04-13 08:06:27 +02:00
|
|
|
PrintToServer("popped: %d, %d", test[0], test[1]);
|
2014-11-09 01:56:56 +01:00
|
|
|
test[0] = stack.Pop(1);
|
2008-04-13 08:06:27 +02:00
|
|
|
PrintToServer("popped: x, %d", test[0]);
|
2014-11-09 01:56:56 +01:00
|
|
|
test[0] = stack.Pop();
|
2008-04-13 08:06:27 +02:00
|
|
|
PrintToServer("popped: %d", test[0]);
|
|
|
|
|
2014-11-09 01:56:56 +01:00
|
|
|
PrintToServer("empty? %d", stack.Empty);
|
2008-04-13 08:06:27 +02:00
|
|
|
|
2014-11-09 01:56:56 +01:00
|
|
|
delete stack;
|
2008-04-13 08:06:27 +02:00
|
|
|
return Plugin_Handled;
|
|
|
|
}
|