00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef ACTION_H
00023 #define ACTION_H
00024
00025 #include <SDL.h>
00026 #include <string>
00027 #include <iostream>
00028 #include <list>
00029 #include "base.h"
00030 #include "../tool/point.h"
00031
00032
00033
00034 class Action
00035 {
00036 private:
00037 std::list<Uint32> var;
00038 Action ( const Action& an_action);
00039 public:
00040 typedef enum
00041 {
00042
00043 ACTION_MOVE_LEFT, ACTION_MOVE_RIGHT, ACTION_UP, ACTION_DOWN, ACTION_JUMP,
00044 ACTION_HIGH_JUMP, ACTION_BACK_JUMP, ACTION_SHOOT, ACTION_CHANGE_WEAPON,
00045 ACTION_WIND, ACTION_NEXT_CHARACTER, ACTION_CHANGE_CHARACTER,
00046 ACTION_CHANGE_TEAM, ACTION_SET_SKIN, ACTION_SYNC_BEGIN,
00047 ACTION_SYNC_END, ACTION_EXPLOSION, ACTION_SUPERTUX_STATE,
00048 ACTION_WEAPON_1, ACTION_WEAPON_2, ACTION_WEAPON_3,
00049 ACTION_WEAPON_4, ACTION_WEAPON_5, ACTION_WEAPON_6,
00050 ACTION_WEAPON_7, ACTION_WEAPON_8, ACTION_WEAPON_9,
00051 ACTION_WEAPON_MORE, ACTION_WEAPON_LESS, ACTION_SET_TARGET,
00052 ACTION_SET_TIMEOUT, ACTION_CONSTRUCTION_UP, ACTION_CONSTRUCTION_DOWN,
00053 ACTION_SET_CHARACTER_ENERGY, ACTION_WEAPON_STOP_USE,
00054
00055
00056 ACTION_PING, ACTION_SET_GAME_MODE, ACTION_SET_MAP,
00057 ACTION_UPDATE_TEAM, ACTION_NEW_TEAM, ACTION_DEL_TEAM,
00058 ACTION_ASK_VERSION, ACTION_ASK_TEAM, ACTION_SEND_VERSION,
00059 ACTION_SEND_TEAM, ACTION_SEND_RANDOM, ACTION_CHAT_MESSAGE,
00060 ACTION_NICKNAME, ACTION_SET_CHARACTER_PHYSICS, ACTION_SET_CHARACTER_DIRECTION,
00061 ACTION_CHANGE_STATE,
00062
00063
00064 ACTION_QUIT, ACTION_WEAPONS1, ACTION_WEAPONS2,
00065 ACTION_WEAPONS3, ACTION_WEAPONS4, ACTION_WEAPONS5,
00066 ACTION_WEAPONS6, ACTION_WEAPONS7, ACTION_WEAPONS8,
00067 ACTION_PAUSE, ACTION_FULLSCREEN, ACTION_TOGGLE_INTERFACE,
00068 ACTION_CENTER, ACTION_TOGGLE_WEAPONS_MENUS, ACTION_CHAT,
00069 } Action_t;
00070
00071 static const Action_t ACTION_FIRST = ACTION_MOVE_LEFT;
00072 static const Action_t ACTION_LAST = ACTION_CHAT;
00073
00074
00075
00076
00077 Action (Action_t type);
00078
00079 Action (Action_t type, int value);
00080 Action (Action_t type, double value);
00081 Action (Action_t type, double value1, int value2);
00082 Action (Action_t type, double value1, double value2);
00083 Action (Action_t type, const std::string& value);
00084
00085
00086 Action (const char* is);
00087
00088 ~Action();
00089
00090 std::ostream& out(std::ostream &os) const;
00091
00092
00093 void Push(int val);
00094 void Push(double val);
00095 void Push(std::string val);
00096 void Push(const Point2i& val);
00097 void Push(const Point2d& val);
00098 int PopInt();
00099 double PopDouble();
00100 std::string PopString();
00101 Point2i PopPoint2i();
00102 Point2d PopPoint2d();
00103 bool IsEmpty() const;
00104
00105
00106 void StoreCharacter(uint team_no, uint char_no);
00107 void StoreActiveCharacter();
00108 void RetrieveCharacter();
00109
00110
00111 void SetTimestamp(uint timestamp);
00112 uint GetTimestamp();
00113
00114 void WritePacket(char* & packet, int & size);
00115 Action_t GetType() const;
00116 protected:
00117 Action_t m_type;
00118 uint m_timestamp;
00119 };
00120
00121
00122
00123 std::ostream& operator<<(std::ostream& os, const Action &a);
00124
00125
00126 #endif