From 0c22da4f4a48edd1f4f50a23f1700ccab320b2e6 Mon Sep 17 00:00:00 2001
From: BAROLLET Theo <theo.barollet@inria.fr>
Date: Wed, 8 Jun 2022 15:47:37 +0200
Subject: [PATCH] added a custom display character to entities

---
 engines/fullgame/map.c            | 4 +++-
 engines/fullgame/map.h            | 4 +++-
 levels/medium/drift_follow/main.c | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/engines/fullgame/map.c b/engines/fullgame/map.c
index 68309a85..5a84c45d 100644
--- a/engines/fullgame/map.c
+++ b/engines/fullgame/map.c
@@ -21,12 +21,13 @@ void place_player(map *m, int y, int x, direction dir) {
     m->player_direction = dir;
 }
 
-void place_entity(map *m, int y, int x, int id, int category, int *stats) {
+void place_entity(map *m, int y, int x, int id, int category, int *stats, char display_symbol) {
     // Creates entity
     entity * e = malloc(sizeof(entity));
     e->id = id;
     e->category = category;
     e->stats = stats;
+    e->display_symbol = display_symbol;
 
     // Place it on the map
     m->entities[coord_idx(y, x)] = e;
@@ -36,6 +37,7 @@ entity * create_entity(char type, int id) {
     entity * i = malloc(sizeof(entity));
     i->id = id;
     i->stats = NULL;
+    i->display_symbol = type;
     switch (type) {
     case '@': i->category = FLAG; break;
     case 'O':
diff --git a/engines/fullgame/map.h b/engines/fullgame/map.h
index a593532e..55348999 100644
--- a/engines/fullgame/map.h
+++ b/engines/fullgame/map.h
@@ -39,6 +39,7 @@ typedef struct Entity {
   int id;       // identifier to display and use in events
   int category; // used to group in events, like monster, NPC...
   int *stats;   // any property the entity may have (life points, state...)
+  char display_symbol; // The symbol of the Entity on an ASCII map
 } entity;
 
 typedef struct Map {
@@ -71,7 +72,8 @@ int player_idx(void);
 map *current_map(void);
 
 void place_player(map *m, int y, int x, direction dir);
-void place_entity(map *m, int y, int x, int id, int category, int *stats);
+void place_entity(map *m, int y, int x, int id, int category, int *stats,
+                  char display_symbol);
 
 void free_map_stack(void);
 
diff --git a/levels/medium/drift_follow/main.c b/levels/medium/drift_follow/main.c
index c63350dd..a205ba86 100644
--- a/levels/medium/drift_follow/main.c
+++ b/levels/medium/drift_follow/main.c
@@ -54,7 +54,7 @@ int main() {
   // Init map and entities
   map * m = create_empty_map("main", 20, 8);
   place_player(m, 4, 8, UNKNOWN);
-  place_entity(m, 4, 3, 0, NPC, NULL);
+  place_entity(m, 4, 3, 0, NPC, NULL, 'P');
 
   init_buffer(&command_buffer);
 
-- 
GitLab