Permalink
Browse files

- Hopefully fixed player timeout

  • Loading branch information...
1 parent ea6fb03 commit 9be1d8045477fd9282ffc041740ca20c4a81cd5d @Jermuk Jermuk committed Oct 14, 2010
Showing with 11 additions and 13 deletions.
  1. +1 −1 include/functions.h
  2. +7 −8 src/functions.c
  3. +1 −1 src/main.c
  4. +2 −2 src/map.c
  5. +0 −1 src/weapons.c
View
@@ -5,7 +5,7 @@
int IsPlayerKnown(struct in_addr ip, u_short port);
void ClearPlayer(int id);
void ClearAllPlayer(void);
-void CheckForTimeout(void);
+void CheckForTimeout(int writesocket);
int GivePlayerWeapon(int id, int wpnid);
void RemovePlayerWeapon(int id, int wpnid);
void RemoveAllPlayerWeapon(int id);
View
@@ -88,17 +88,18 @@ void ClearAllPlayer(void)
}
/**
- * \fn void CheckForTimeout(void)
+ * \fn void CheckForTimeout(int writesocket)
* \brief check all player for timeout
*/
-void CheckForTimeout(void)
+void CheckForTimeout(int writesocket)
{
int 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);
+ SendLeaveMessage(i, writesocket);
ClearPlayer(i);
}
}
@@ -175,17 +176,15 @@ void RemoveAllPlayerWeapon(int id)
*/
int PlayerTimeout(int id)
{
- id = 0;
- /*
+ //id = 0;
+
time_t 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 0;
}
View
@@ -26,7 +26,7 @@ int main()
while(1)
{
- CheckForTimeout();
+ CheckForTimeout(readsocket);
PingAllPlayer(readsocket);
CheckAllPlayerForReload(readsocket);
View
@@ -42,11 +42,11 @@ void ReadMap()
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");
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");
int b;
for(b = 0; b <= maxy; b++)
View
@@ -39,7 +39,6 @@ void WeaponInit()
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(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.