Skip to content

Commit

Permalink
- Hopefully fixed player timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Jermuk committed Oct 14, 2010
1 parent ea6fb03 commit 9be1d80
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/functions.h
Expand Up @@ -5,7 +5,7 @@
int IsPlayerKnown(struct in_addr ip, u_short port); int IsPlayerKnown(struct in_addr ip, u_short port);
void ClearPlayer(int id); void ClearPlayer(int id);
void ClearAllPlayer(void); void ClearAllPlayer(void);
void CheckForTimeout(void); void CheckForTimeout(int writesocket);
int GivePlayerWeapon(int id, int wpnid); int GivePlayerWeapon(int id, int wpnid);
void RemovePlayerWeapon(int id, int wpnid); void RemovePlayerWeapon(int id, int wpnid);
void RemoveAllPlayerWeapon(int id); void RemoveAllPlayerWeapon(int id);
Expand Down
15 changes: 7 additions & 8 deletions src/functions.c
Expand Up @@ -88,17 +88,18 @@ void ClearAllPlayer(void)
} }


/** /**
* \fn void CheckForTimeout(void) * \fn void CheckForTimeout(int writesocket)
* \brief check all player for timeout * \brief check all player for timeout
*/ */
void CheckForTimeout(void) void CheckForTimeout(int writesocket)
{ {
int i; int i;
for (i = 1; i <= sv_maxplayers; i++) for (i = 1; i <= sv_maxplayers; i++)
{ {
if (PlayerTimeout(i)) if (player[i].used == 1 && PlayerTimeout(i))
{ {
printf("Client %d timed out!\n", i); printf("Client %d timed out!\n", i);
SendLeaveMessage(i, writesocket);
ClearPlayer(i); ClearPlayer(i);
} }
} }
Expand Down Expand Up @@ -175,17 +176,15 @@ void RemoveAllPlayerWeapon(int id)
*/ */
int PlayerTimeout(int id) int PlayerTimeout(int id)
{ {
id = 0; //id = 0;
/*
time_t actualtime; time_t actualtime;
time(&actualtime); time(&actualtime);


if(((player[id].lastpaket + TIMEOUT) > actualtime) && player[id].lastpaket != 0) if(((player[id].lastpaket + TIMEOUT) < actualtime) && player[id].lastpaket != 0)
{ {
printf("POSITIV!\n");
return 1; return 1;
} }
*/
return 0; return 0;
} }


Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Expand Up @@ -26,7 +26,7 @@ int main()
while(1) while(1)
{ {


CheckForTimeout(); CheckForTimeout(readsocket);
PingAllPlayer(readsocket); PingAllPlayer(readsocket);
CheckAllPlayerForReload(readsocket); CheckAllPlayerForReload(readsocket);


Expand Down
4 changes: 2 additions & 2 deletions src/map.c
Expand Up @@ -42,11 +42,11 @@ void ReadMap()
tilemode[i] = ReadByte(file); tilemode[i] = ReadByte(file);
} }


map = malloc(maxx+1 * sizeof(struct TILE *)); map = malloc(maxx * sizeof(struct TILE *));
if(map == NULL) error_exit("Memory error in ReadMap()\n"); if(map == NULL) error_exit("Memory error in ReadMap()\n");
for(i = 0; i <= maxx; i++) for(i = 0; i <= maxx; i++)
{ {
map[i] = malloc(maxy+1 * sizeof(struct TILE *)); map[i] = malloc(maxy * sizeof(struct TILE *));
if(map[i] == NULL) error_exit("Memory error in ReadMap()\n"); if(map[i] == NULL) error_exit("Memory error in ReadMap()\n");
int b; int b;
for(b = 0; b <= maxy; b++) for(b = 0; b <= maxy; b++)
Expand Down
1 change: 0 additions & 1 deletion src/weapons.c
Expand Up @@ -39,7 +39,6 @@ void WeaponInit()
AddWeapon(5, "Elite" , 22 , 0, 0, 187 , 1, 2,1000, 300, 0 , 13, 120, 1000); AddWeapon(5, "Elite" , 22 , 0, 0, 187 , 1, 2,1000, 300, 0 , 13, 120, 1000);
AddWeapon(6, "Five-Seven" , 21 , 0, 0, 187 , 1, 2,750 , 300, 0 , 20, 100, 2000); AddWeapon(6, "Five-Seven" , 21 , 0, 0, 187 , 1, 2,750 , 300, 0 , 20, 100, 2000);
AddWeapon(50, "Knife", 100, 0, 0, 1 , 1, 2, 0 , 8 , 0 , -1, -1 , 0); AddWeapon(50, "Knife", 100, 0, 0, 1 , 1, 2, 0 , 8 , 0 , -1, -1 , 0);
//FIXME finish reload
} }




0 comments on commit 9be1d80

Please sign in to comment.