From f183008374138f1f0d36aea1414e95ad12846994 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Wed, 14 May 2008 22:34:06 +0000 Subject: [PATCH] Basic, non-typesafe implementation of primitive resource types. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2972 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/resource/propfile.h | 2 +- sc2/src/sc2code/libs/resource/resinit.c | 26 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/sc2/src/sc2code/libs/resource/propfile.h b/sc2/src/sc2code/libs/resource/propfile.h index a1469b114..12d6445e5 100644 --- a/sc2/src/sc2code/libs/resource/propfile.h +++ b/sc2/src/sc2code/libs/resource/propfile.h @@ -27,4 +27,4 @@ void PropFile_from_string (char *d, PROPERTY_HANDLER handler); void PropFile_from_file (uio_Stream *f, PROPERTY_HANDLER handler); void PropFile_from_filename (uio_DirHandle *path, const char *fname, PROPERTY_HANDLER handler); -#endif \ No newline at end of file +#endif diff --git a/sc2/src/sc2code/libs/resource/resinit.c b/sc2/src/sc2code/libs/resource/resinit.c index a55967595..35f5cb250 100644 --- a/sc2/src/sc2code/libs/resource/resinit.c +++ b/sc2/src/sc2code/libs/resource/resinit.c @@ -134,9 +134,30 @@ process_resource_desc (const char *key, const char *value) void * UseDescriptorAsRes (const char *descriptor) { - return descriptor; + return (void *)descriptor; } +void * +DescriptorToInt (const char *descriptor) +{ + intptr_t value = atoi(descriptor); + return (void *) value; +} + +void * +DescriptorToBoolean (const char *descriptor) +{ + if (!stricmp(descriptor, "true")) + { + return (void *)(1); + } + else + { + return (void *)(0); + } +} + + BOOLEAN NullFreeRes (void *data) { @@ -152,6 +173,9 @@ InitResourceSystem (void) _set_current_index_header (ndx); InstallResTypeVectors ("UNKNOWNRES", UseDescriptorAsRes, NullFreeRes); + InstallResTypeVectors ("STRING", UseDescriptorAsRes, NullFreeRes); + InstallResTypeVectors ("INT32", DescriptorToInt, NullFreeRes); + InstallResTypeVectors ("BOOLEAN", DescriptorToBoolean, NullFreeRes); InstallGraphicResTypes (); InstallStringTableResType (); InstallAudioResTypes ();