From be25be22d818c1f94dbe844cb9ea27132c130450 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 16 Oct 2011 14:01:45 -0700 Subject: game: Add game_game_get_resource() For now it's equivalent to game_game_get_object() restricted to resources. --- libgame/game-game.c | 15 +++++++++++++++ libgame/game-game.h | 3 +++ libgame/game-resource.h | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libgame/game-game.c b/libgame/game-game.c index 2968824..67decd7 100644 --- a/libgame/game-game.c +++ b/libgame/game-game.c @@ -1100,3 +1100,18 @@ game_game_get_object (GameGame *game, const char *name) return g_hash_table_lookup (game->named_objects, name); } +GameResource * +game_game_get_resource (GameGame *game, const char *name) +{ + gpointer p; + + g_return_val_if_fail (GAME_IS_GAME (game), NULL); + g_return_val_if_fail (name != NULL, NULL); + + p = g_hash_table_lookup (game->named_objects, name); + if (GAME_IS_RESOURCE (p)) + return p; + else + return NULL; +} + diff --git a/libgame/game-game.h b/libgame/game-game.h index e3bc450..ff9d93d 100644 --- a/libgame/game-game.h +++ b/libgame/game-game.h @@ -39,6 +39,7 @@ typedef struct _GameGraphic GameGraphic; typedef struct _GameGraphicClass GameGraphicClass; typedef struct _GameMatch GameMatch; typedef struct _GameMatchClass GameMatchClass; +typedef struct _GameResource GameResource; typedef struct _GameGame GameGame; typedef struct _GameGameClass GameGameClass; @@ -130,6 +131,8 @@ guint game_game_get_max_players (GameGame * game); GameObject * game_game_get_object (GameGame * game, const char * name); +GameResource * game_game_get_resource (GameGame * game, + const char * name); GameContainer * game_game_get_players (GameGame * game); guint game_game_get_player_count (GameGame * game); diff --git a/libgame/game-resource.h b/libgame/game-resource.h index 0fe7aa7..81bb998 100644 --- a/libgame/game-resource.h +++ b/libgame/game-resource.h @@ -30,7 +30,7 @@ G_BEGIN_DECLS #define GAME_IS_RESOURCE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAME_TYPE_RESOURCE)) #define GAME_RESOURCE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GAME_TYPE_RESOURCE, GameResourceClass)) -typedef struct _GameResource GameResource; +//typedef struct _GameResource GameResource; typedef struct _GameResourceClass GameResourceClass; struct _GameResource { -- cgit v1.2.3