#include <action.h>
Definition at line 34 of file action.h.
enum Action::Action_t |
Definition at line 40 of file action.h.
00041 { 00042 // Game action. 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 // Game initialisation 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 // Out of game actions (local only). 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;
Action::Action | ( | const Action & | an_action | ) | [private] |
Action::Action | ( | Action_t | type | ) |
Definition at line 33 of file action.cpp.
00034 { 00035 var.clear(); 00036 m_type = type; 00037 m_timestamp = Time::GetInstance()->Read(); 00038 }
Here is the call graph for this function:
Action::Action | ( | Action_t | type, | |
int | value | |||
) |
Definition at line 41 of file action.cpp.
00041 : m_type(type) 00042 { 00043 var.clear(); 00044 Push(value); 00045 m_timestamp = Time::GetInstance()->Read(); 00046 }
Here is the call graph for this function:
Action::Action | ( | Action_t | type, | |
double | value | |||
) |
Definition at line 48 of file action.cpp.
00048 : m_type(type) 00049 { 00050 var.clear(); 00051 Push(value); 00052 m_timestamp = Time::GetInstance()->Read(); 00053 }
Here is the call graph for this function:
Action::Action | ( | Action_t | type, | |
double | value1, | |||
int | value2 | |||
) |
Definition at line 70 of file action.cpp.
00070 : m_type(type) 00071 { 00072 var.clear(); 00073 Push(value1); 00074 Push(value2); 00075 m_timestamp = Time::GetInstance()->Read(); 00076 }
Here is the call graph for this function:
Action::Action | ( | Action_t | type, | |
double | value1, | |||
double | value2 | |||
) |
Definition at line 62 of file action.cpp.
00062 : m_type(type) 00063 { 00064 var.clear(); 00065 Push(value1); 00066 Push(value2); 00067 m_timestamp = Time::GetInstance()->Read(); 00068 }
Here is the call graph for this function:
Action::Action | ( | Action_t | type, | |
const std::string & | value | |||
) |
Definition at line 55 of file action.cpp.
00055 : m_type(type) 00056 { 00057 var.clear(); 00058 Push(value); 00059 m_timestamp = Time::GetInstance()->Read(); 00060 }
Here is the call graph for this function:
Action::Action | ( | const char * | is | ) |
Definition at line 79 of file action.cpp.
00080 { 00081 var.clear(); 00082 m_type = (Action_t)SDLNet_Read32(is); 00083 is += 4; 00084 m_timestamp = (Action_t)SDLNet_Read32(is); 00085 is += 4; 00086 int m_lenght = SDLNet_Read32(is); 00087 is += 4; 00088 00089 for(int i=0; i < m_lenght; i++) 00090 { 00091 Uint32 val = SDLNet_Read32(is); 00092 var.push_back(val); 00093 is += 4; 00094 } 00095 }
Action::~Action | ( | ) |
uint Action::GetTimestamp | ( | ) |
Action::Action_t Action::GetType | ( | ) | const |
Definition at line 101 of file action.cpp.
00102 { 00103 return m_type; 00104 }
Here is the caller graph for this function:
bool Action::IsEmpty | ( | ) | const |
std::ostream& Action::out | ( | std::ostream & | os | ) | const |
double Action::PopDouble | ( | ) |
Definition at line 232 of file action.cpp.
00233 { 00234 assert(var.size() > 0); 00235 if(var.size() <= 0) 00236 return 0.0; 00237 double val; 00238 Uint32 tmp[2]; 00239 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN) 00240 tmp[0] = var.front(); 00241 var.pop_front(); 00242 tmp[1] = var.front(); 00243 var.pop_front(); 00244 memcpy(&val, &tmp, 8); 00245 #else 00246 tmp[1] = var.front(); 00247 var.pop_front(); 00248 tmp[0] = var.front(); 00249 var.pop_front(); 00250 memcpy(&val, &tmp, 8); 00251 #endif 00252 00253 MSG_DEBUG( "action", " (%s) Poping double : %f", 00254 ActionHandler::GetInstance()->GetActionName(m_type).c_str(), val); 00255 return val; 00256 }
Here is the call graph for this function:
Here is the caller graph for this function:
int Action::PopInt | ( | ) |
Definition at line 218 of file action.cpp.
00219 { 00220 assert(var.size() > 0); 00221 if(var.size() <= 0) 00222 return 0; 00223 int val; 00224 Uint32 tmp = var.front(); 00225 memcpy(&val, &tmp, 4); 00226 var.pop_front(); 00227 MSG_DEBUG( "action", " (%s) Poping int : %i", 00228 ActionHandler::GetInstance()->GetActionName(m_type).c_str(), val); 00229 return val; 00230 }
Here is the call graph for this function:
Here is the caller graph for this function:
Point2d Action::PopPoint2d | ( | ) |
Definition at line 303 of file action.cpp.
00304 { 00305 double x, y; 00306 x = PopDouble(); 00307 y = PopDouble(); 00308 return Point2d(x, y); 00309 }
Here is the call graph for this function:
Here is the caller graph for this function:
Point2i Action::PopPoint2i | ( | ) |
Definition at line 295 of file action.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
std::string Action::PopString | ( | ) |
Definition at line 258 of file action.cpp.
00259 { 00260 assert(var.size() > 1); 00261 if(var.size() <= 1) 00262 return ""; 00263 int lenght = PopInt(); 00264 00265 std::string str=""; 00266 00267 assert((int)var.size() >= lenght/4); 00268 if((int)var.size() < lenght/4) 00269 return ""; 00270 00271 while(lenght > 0) 00272 { 00273 Uint32 tmp = var.front(); 00274 var.pop_front(); 00275 char tmp_str[5] = {0, 0, 0, 0, 0}; 00276 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN) 00277 memcpy(tmp_str, &tmp, 4); 00278 str += tmp_str; 00279 lenght -= 4; 00280 #else 00281 char* c_tmp_str = (char*)(&tmp_str) + 3; 00282 char* c_tmp = (char*)&tmp; 00283 for(int i=0; i < 4; i++) 00284 *(c_tmp_str--) = *(c_tmp++); 00285 00286 str += tmp_str; 00287 lenght -= 4; 00288 #endif 00289 } 00290 MSG_DEBUG( "action", " (%s) Poping string : %s", 00291 ActionHandler::GetInstance()->GetActionName(m_type).c_str(), str.c_str()); 00292 return str; 00293 }
Here is the call graph for this function:
Here is the caller graph for this function:
void Action::Push | ( | const Point2d & | val | ) |
void Action::Push | ( | const Point2i & | val | ) |
void Action::Push | ( | std::string | val | ) |
Definition at line 186 of file action.cpp.
00187 { 00188 //Cut the string into 32bit values 00189 //But first, we write the size of the string: 00190 Push((int)val.size()); 00191 char* ch = (char*)val.c_str(); 00192 00193 int count = val.size(); 00194 while(count > 0) 00195 { 00196 Uint32 tmp = 0; 00197 // Fix-me : We are reading out of the c_str() buffer there : 00198 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN) 00199 strncpy((char*)&tmp, ch, 4); 00200 var.push_back(tmp); 00201 ch += 4; 00202 count -= 4; 00203 #else 00204 char* c_tmp = (char*)&tmp; 00205 c_tmp +=3; 00206 for(int i=0; i < 4; i++) 00207 *(c_tmp--) = *(ch++); 00208 00209 var.push_back(tmp); 00210 count -= 4; 00211 #endif 00212 } 00213 MSG_DEBUG( "action", " (%s) Pushing string : %s", 00214 ActionHandler::GetInstance()->GetActionName(m_type).c_str(), val.c_str()); 00215 }
Here is the call graph for this function:
void Action::Push | ( | double | val | ) |
Definition at line 158 of file action.cpp.
00159 { 00160 Uint32 tmp[2]; 00161 memcpy(&tmp, &val, 8); 00162 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN) 00163 var.push_back(tmp[0]); 00164 var.push_back(tmp[1]); 00165 #else 00166 var.push_back(tmp[1]); 00167 var.push_back(tmp[0]); 00168 #endif 00169 00170 MSG_DEBUG( "action", " (%s) Pushing double : %f", 00171 ActionHandler::GetInstance()->GetActionName(m_type).c_str(), val); 00172 }
Here is the call graph for this function:
void Action::Push | ( | int | val | ) |
Definition at line 148 of file action.cpp.
00149 { 00150 Uint32 tmp; 00151 memcpy(&tmp, &val, 4); 00152 var.push_back(tmp); 00153 MSG_DEBUG( "action", " (%s) Pushing int : %i", 00154 ActionHandler::GetInstance()->GetActionName(m_type).c_str(), val); 00155 00156 }
Here is the call graph for this function:
Here is the caller graph for this function:
void Action::RetrieveCharacter | ( | ) |
Definition at line 339 of file action.cpp.
00340 { 00341 int team_no = PopInt(); 00342 int char_no = PopInt(); 00343 Character * c = teams_list.FindPlayingByIndex(team_no)->FindByIndex(char_no); 00344 c->SetXY(PopPoint2i()); 00345 c->SetDirection((Body::Direction_t)PopInt()); 00346 c->SetFiringAngle(PopDouble()); 00347 c->SetEnergy(PopInt()); 00348 int disease_damage_per_turn = PopInt(); 00349 int disease_duration = PopInt(); 00350 c->SetDiseaseDamage(disease_damage_per_turn, disease_duration); 00351 c->SetSpeedXY(PopPoint2d()); 00352 if((bool)PopInt()) { // If active characters, retrieve stored animation 00353 if(c->GetTeam().IsActiveTeam()) 00354 ActiveTeam().SelectCharacter(char_no); 00355 c->SetClothe(PopString()); 00356 c->SetMovement(PopString()); 00357 c->GetBody()->SetFrame((uint)PopInt()); 00358 } 00359 }
Here is the call graph for this function:
void Action::SetTimestamp | ( | uint | timestamp | ) |
void Action::StoreActiveCharacter | ( | ) |
Definition at line 312 of file action.cpp.
00313 { 00314 StoreCharacter(ActiveCharacter().GetTeamIndex() ,ActiveCharacter().GetCharacterIndex()); 00315 }
Here is the call graph for this function:
Here is the caller graph for this function:
Definition at line 317 of file action.cpp.
00318 { 00319 Push((int)team_no); 00320 Push((int)char_no); 00321 Character * c = teams_list.FindPlayingByIndex(team_no)->FindByIndex(char_no); 00322 Push(c->GetPosition()); 00323 Push((int)c->GetDirection()); 00324 Push(c->GetAbsFiringAngle()); 00325 Push(c->GetEnergy()); 00326 Push((int)c->GetDiseaseDamage()); 00327 Push((int)c->GetDiseaseDuration()); 00328 Push(c->GetSpeed()); 00329 if(c->IsActiveCharacter()) { // If active character, store step animation 00330 Push((int)true); 00331 Push(ActiveTeam().ActiveCharacter().GetBody()->GetClothe()); 00332 Push(ActiveTeam().ActiveCharacter().GetBody()->GetMovement()); 00333 Push((int)ActiveTeam().ActiveCharacter().GetBody()->GetFrame()); 00334 } else { 00335 Push((int)false); 00336 } 00337 }
Here is the call graph for this function:
Here is the caller graph for this function:
void Action::WritePacket | ( | char *& | packet, | |
int & | size | |||
) |
Definition at line 122 of file action.cpp.
00123 { 00124 size = 4 //Size of the type; 00125 + 4 //Size of the timestamp 00126 + 4 //Size of the number of variable 00127 + int(var.size()) * 4; 00128 00129 packet = (char*)malloc(size); 00130 char* os = packet; 00131 00132 SDLNet_Write32(m_type, os); 00133 os += 4; 00134 SDLNet_Write32(m_timestamp, os); 00135 os += 4; 00136 Uint32 param_size = (Uint32)var.size(); 00137 SDLNet_Write32(param_size, os); 00138 os += 4; 00139 00140 for(std::list<Uint32>::iterator val = var.begin(); val!=var.end(); val++) 00141 { 00142 SDLNet_Write32(*val, os); 00143 os += 4; 00144 } 00145 }
const Action_t Action::ACTION_FIRST = ACTION_MOVE_LEFT [static] |
const Action_t Action::ACTION_LAST = ACTION_CHAT [static] |
uint Action::m_timestamp [protected] |
Action_t Action::m_type [protected] |
std::list<Uint32> Action::var [private] |