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