Changed player names to allocated strings to be friendly to Scheme!
This commit is contained in:
parent
3873192547
commit
30e63d36b5
|
@ -31,6 +31,7 @@ struct Player * createNewPlayer(struct ClientConnection * connection)
|
|||
{
|
||||
struct Player * newPlayer = calloc(1, sizeof(struct Player));
|
||||
newPlayer->connection = connection;
|
||||
newPlayer->name = calloc(PLAYER_NAME_LENGTH, sizeof(char));
|
||||
|
||||
return newPlayer;
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ struct Player * createNewPlayer(struct ClientConnection * connection)
|
|||
// Deallocates a player:
|
||||
void deallocatePlayer(struct Player ** player)
|
||||
{
|
||||
free((*player)->name);
|
||||
free(*player);
|
||||
*player = NULL;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// =========================================
|
||||
#ifndef PLAYER_DATA_H
|
||||
#define PLAYER_DATA_H
|
||||
#define PLAYER_NAME_LENGTH 64
|
||||
#include <stdbool.h>
|
||||
#include "connections.h"
|
||||
|
||||
|
@ -14,7 +15,7 @@
|
|||
struct Player
|
||||
{
|
||||
struct ClientConnection * connection;
|
||||
char name[64];
|
||||
char * name;
|
||||
};
|
||||
|
||||
// Functions:
|
||||
|
|
Loading…
Reference in New Issue