You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(147) |
Oct
(219) |
Nov
(189) |
Dec
(380) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(301) |
Feb
(369) |
Mar
(155) |
Apr
(61) |
May
(77) |
Jun
(101) |
Jul
(191) |
Aug
(107) |
Sep
(180) |
Oct
(37) |
Nov
(7) |
Dec
(28) |
2004 |
Jan
(34) |
Feb
(45) |
Mar
(7) |
Apr
(17) |
May
(6) |
Jun
(59) |
Jul
(4) |
Aug
(8) |
Sep
(6) |
Oct
(18) |
Nov
(11) |
Dec
(15) |
2005 |
Jan
(148) |
Feb
(146) |
Mar
(73) |
Apr
(154) |
May
(192) |
Jun
(11) |
Jul
(23) |
Aug
(23) |
Sep
(26) |
Oct
(68) |
Nov
(109) |
Dec
(294) |
2006 |
Jan
(172) |
Feb
(22) |
Mar
(81) |
Apr
(79) |
May
(83) |
Jun
(23) |
Jul
(35) |
Aug
(66) |
Sep
(39) |
Oct
(133) |
Nov
(125) |
Dec
(90) |
2007 |
Jan
(49) |
Feb
(21) |
Mar
(3) |
Apr
(33) |
May
(19) |
Jun
(26) |
Jul
(32) |
Aug
(18) |
Sep
(14) |
Oct
(2) |
Nov
(8) |
Dec
(22) |
2008 |
Jan
(23) |
Feb
(14) |
Mar
(28) |
Apr
(11) |
May
(55) |
Jun
(8) |
Jul
(1) |
Aug
(36) |
Sep
(8) |
Oct
(20) |
Nov
(6) |
Dec
|
2009 |
Jan
(2) |
Feb
(7) |
Mar
|
Apr
(1) |
May
(2) |
Jun
(46) |
Jul
(15) |
Aug
(1) |
Sep
(3) |
Oct
(88) |
Nov
(108) |
Dec
(119) |
2010 |
Jan
(31) |
Feb
(3) |
Mar
(5) |
Apr
(1) |
May
(5) |
Jun
(5) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
(23) |
Mar
(1) |
Apr
(20) |
May
(27) |
Jun
(2) |
Jul
(40) |
Aug
(14) |
Sep
(17) |
Oct
(5) |
Nov
|
Dec
(28) |
2012 |
Jan
(31) |
Feb
(19) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <Mee...@us...> - 2011-12-21 17:59:06
|
Revision: 3707 http://sc2.svn.sourceforge.net/sc2/?rev=3707&view=rev Author: Meep-Eep Date: 2011-12-21 17:58:57 +0000 (Wed, 21 Dec 2011) Log Message: ----------- Removed a few explicit casts which caused warnings. (From louisdx) Modified Paths: -------------- trunk/sc2/src/libs/heap/heap.c trunk/sc2/src/libs/uio/hashtable.c Modified: trunk/sc2/src/libs/heap/heap.c =================================================================== --- trunk/sc2/src/libs/heap/heap.c 2011-12-21 17:43:44 UTC (rev 3706) +++ trunk/sc2/src/libs/heap/heap.c 2011-12-21 17:58:57 UTC (rev 3707) @@ -49,7 +49,7 @@ heap->minSize = minSize; heap->minFillQuotient = minFillQuotient; heap->size = nextPower2(initialSize); - heap->minFill = (size_t) ceil(((double) (heap->size >> 1)) + heap->minFill = ceil(((double) (heap->size >> 1)) * heap->minFillQuotient); heap->entries = malloc(heap->size * sizeof (HeapValue *)); heap->numEntries = 0; Modified: trunk/sc2/src/libs/uio/hashtable.c =================================================================== --- trunk/sc2/src/libs/uio/hashtable.c 2011-12-21 17:43:44 UTC (rev 3706) +++ trunk/sc2/src/libs/uio/hashtable.c 2011-12-21 17:58:57 UTC (rev 3707) @@ -169,12 +169,12 @@ HASHTABLE_(setup)(HASHTABLE_(HashTable) *hashTable, uio_uint32 initialSize) { if (initialSize < 4) initialSize = 4; - hashTable->size = nextPower2((uio_uint32) ceil( - ((double) initialSize) / hashTable->maxFillQuotient)); + hashTable->size = nextPower2(ceil(((double) initialSize) / + hashTable->maxFillQuotient)); hashTable->hashMask = hashTable->size - 1; - hashTable->minSize = (uio_uint32) ceil(((double) (hashTable->size >> 1)) + hashTable->minSize = ceil(((double) (hashTable->size >> 1)) * hashTable->minFillQuotient); - hashTable->maxSize = (uio_uint32) floor(((double) hashTable->size) + hashTable->maxSize = floor(((double) hashTable->size) * hashTable->maxFillQuotient); hashTable->entries = uio_calloc(hashTable->size, sizeof (HASHTABLE_(HashEntry) *)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-12-21 17:43:51
|
Revision: 3706 http://sc2.svn.sourceforge.net/sc2/?rev=3706&view=rev Author: Meep-Eep Date: 2011-12-21 17:43:44 +0000 (Wed, 21 Dec 2011) Log Message: ----------- Remove superfluous semicolons, from Louis Delacroix. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/network/connect/connect.c trunk/sc2/src/libs/network/connect/listen.c trunk/sc2/src/libs/network/connect/resolve.c trunk/sc2/src/uqm/supermelee/netplay/packethandlers.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-12-20 22:15:43 UTC (rev 3705) +++ trunk/sc2/ChangeLog 2011-12-21 17:43:44 UTC (rev 3706) @@ -1,4 +1,5 @@ Changes towards version 0.8: +- Remove superfluous semicolons, from Louis Delacroix - Added a free callback function for the values of the key-value pairs in hash tables - SvdB - Annigilate ActivateStarShip() - SvdB Modified: trunk/sc2/src/libs/network/connect/connect.c =================================================================== --- trunk/sc2/src/libs/network/connect/connect.c 2011-12-20 22:15:43 UTC (rev 3705) +++ trunk/sc2/src/libs/network/connect/connect.c 2011-12-21 17:43:44 UTC (rev 3706) @@ -57,7 +57,7 @@ static ConnectState * ConnectState_alloc(void) { return (ConnectState *) malloc(sizeof (ConnectState)); -}; +} static void ConnectState_free(ConnectState *connectState) { Modified: trunk/sc2/src/libs/network/connect/listen.c =================================================================== --- trunk/sc2/src/libs/network/connect/listen.c 2011-12-20 22:15:43 UTC (rev 3705) +++ trunk/sc2/src/libs/network/connect/listen.c 2011-12-21 17:43:44 UTC (rev 3706) @@ -56,7 +56,7 @@ static ListenState * ListenState_alloc(void) { return (ListenState *) malloc(sizeof (ListenState)); -}; +} static void ListenState_free(ListenState *listenState) { Modified: trunk/sc2/src/libs/network/connect/resolve.c =================================================================== --- trunk/sc2/src/libs/network/connect/resolve.c 2011-12-20 22:15:43 UTC (rev 3705) +++ trunk/sc2/src/libs/network/connect/resolve.c 2011-12-21 17:43:44 UTC (rev 3706) @@ -33,7 +33,7 @@ static ResolveState * ResolveState_new(void) { return (ResolveState *) malloc(sizeof (ResolveState)); -}; +} static void ResolveState_free(ResolveState *resolveState) { Modified: trunk/sc2/src/uqm/supermelee/netplay/packethandlers.h =================================================================== --- trunk/sc2/src/uqm/supermelee/netplay/packethandlers.h 2011-12-20 22:15:43 UTC (rev 3705) +++ trunk/sc2/src/uqm/supermelee/netplay/packethandlers.h 2011-12-21 17:43:44 UTC (rev 3706) @@ -27,7 +27,7 @@ #define DECLARE_PACKETHANDLER(type) \ int PacketHandler_##type(NetConnection *conn, \ - const Packet_##type *packet); + const Packet_##type *packet) DECLARE_PACKETHANDLER(Init); DECLARE_PACKETHANDLER(Ping); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-12-20 22:15:49
|
Revision: 3705 http://sc2.svn.sourceforge.net/sc2/?rev=3705&view=rev Author: Meep-Eep Date: 2011-12-20 22:15:43 +0000 (Tue, 20 Dec 2011) Log Message: ----------- Fix comment. Modified Paths: -------------- trunk/sc2/src/libs/uio/charhashtable.h Modified: trunk/sc2/src/libs/uio/charhashtable.h =================================================================== --- trunk/sc2/src/libs/uio/charhashtable.h 2011-12-20 21:55:41 UTC (rev 3704) +++ trunk/sc2/src/libs/uio/charhashtable.h 2011-12-20 22:15:43 UTC (rev 3705) @@ -35,5 +35,5 @@ #include "hashtable.h" -#endif /* _HASHTABLE_H */ +#endif /* _CHARHASHTABLE_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-12-20 21:55:47
|
Revision: 3704 http://sc2.svn.sourceforge.net/sc2/?rev=3704&view=rev Author: Meep-Eep Date: 2011-12-20 21:55:41 +0000 (Tue, 20 Dec 2011) Log Message: ----------- Make some declarations forward declartions, to prevent dependency hell in upcoming changes. Modified Paths: -------------- trunk/sc2/src/libs/resource/index.h Modified: trunk/sc2/src/libs/resource/index.h =================================================================== --- trunk/sc2/src/libs/resource/index.h 2011-12-20 20:16:17 UTC (rev 3703) +++ trunk/sc2/src/libs/resource/index.h 2011-12-20 21:55:41 UTC (rev 3704) @@ -19,19 +19,22 @@ #ifndef _INDEX_H #define _INDEX_H +typedef struct resource_handlers ResourceHandlers; +typedef struct resource_desc ResourceDesc; + #include <stdio.h> #include "libs/reslib.h" #include "libs/uio/charhashtable.h" -typedef struct resource_handlers +struct resource_handlers { const char *resType; ResourceLoadFun *loadFun; ResourceFreeFun *freeFun; ResourceStringFun *toString; -} ResourceHandlers; +}; -typedef struct resource_desc +struct resource_desc { RESOURCE res_id; char *fname; @@ -39,7 +42,7 @@ RESOURCE_DATA resdata; // refcount is rudimentary as nothing really frees the descriptors unsigned refcount; -} ResourceDesc; +}; struct resource_index_desc { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-12-20 20:16:23
|
Revision: 3703 http://sc2.svn.sourceforge.net/sc2/?rev=3703&view=rev Author: Meep-Eep Date: 2011-12-20 20:16:17 +0000 (Tue, 20 Dec 2011) Log Message: ----------- Added a callback function for keys. Also some more comments. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/file/files.c trunk/sc2/src/libs/resource/resinit.c trunk/sc2/src/libs/uio/charhashtable.c trunk/sc2/src/libs/uio/charhashtable.h trunk/sc2/src/libs/uio/gphys.h trunk/sc2/src/libs/uio/hashtable.c trunk/sc2/src/libs/uio/hashtable.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-12-16 21:01:55 UTC (rev 3702) +++ trunk/sc2/ChangeLog 2011-12-20 20:16:17 UTC (rev 3703) @@ -1,4 +1,6 @@ Changes towards version 0.8: +- Added a free callback function for the values of the key-value pairs + in hash tables - SvdB - Annigilate ActivateStarShip() - SvdB - Removed obsolete RESPONSE_TO_REF() - SvdB - Don't require the 'shadow' dir in addon packs, from Alex Modified: trunk/sc2/src/libs/file/files.c =================================================================== --- trunk/sc2/src/libs/file/files.c 2011-12-16 21:01:55 UTC (rev 3702) +++ trunk/sc2/src/libs/file/files.c 2011-12-20 20:16:17 UTC (rev 3703) @@ -94,7 +94,7 @@ buf = HMalloc(BUFSIZE); // This was originally a statically allocated buffer, // but as this function might be run from a thread with - // a small Stack, this is better. + // a small stack, this is better. while (1) { numInBuf = uio_read (src, buf, BUFSIZE); Modified: trunk/sc2/src/libs/resource/resinit.c =================================================================== --- trunk/sc2/src/libs/resource/resinit.c 2011-12-16 21:01:55 UTC (rev 3702) +++ trunk/sc2/src/libs/resource/resinit.c 2011-12-20 20:16:17 UTC (rev 3703) @@ -34,7 +34,8 @@ static RESOURCE_INDEX allocResourceIndex (void) { RESOURCE_INDEX ndx = HMalloc (sizeof (RESOURCE_INDEX_DESC)); - ndx->map = CharHashTable_newHashTable (NULL, NULL, NULL, NULL, 0, 0.85, 0.9); + ndx->map = CharHashTable_newHashTable (NULL, NULL, NULL, NULL, NULL, + 0, 0.85, 0.9); return ndx; } Modified: trunk/sc2/src/libs/uio/charhashtable.c =================================================================== --- trunk/sc2/src/libs/uio/charhashtable.c 2011-12-16 21:01:55 UTC (rev 3702) +++ trunk/sc2/src/libs/uio/charhashtable.c 2011-12-20 20:16:17 UTC (rev 3703) @@ -30,7 +30,7 @@ const char *key1, const char *key2); static inline char *CharHashTable_copy(CharHashTable_HashTable *hashTable, const char *key); -static inline void CharHashTable_free(CharHashTable_HashTable *hashTable, +static inline void CharHashTable_freeKey(CharHashTable_HashTable *hashTable, char *key); #include "hashtable.c" @@ -68,7 +68,7 @@ } static inline void -CharHashTable_free(CharHashTable_HashTable *hashTable, +CharHashTable_freeKey(CharHashTable_HashTable *hashTable, char *key) { (void) *hashTable; uio_free(key); Modified: trunk/sc2/src/libs/uio/charhashtable.h =================================================================== --- trunk/sc2/src/libs/uio/charhashtable.h 2011-12-16 21:01:55 UTC (rev 3702) +++ trunk/sc2/src/libs/uio/charhashtable.h 2011-12-20 20:16:17 UTC (rev 3703) @@ -28,7 +28,9 @@ #define CharHashTable_HASH CharHashTable_hash #define CharHashTable_EQUAL CharHashTable_equal #define CharHashTable_COPY CharHashTable_copy -#define CharHashTable_FREE CharHashTable_free +#define CharHashTable_FREEKEY CharHashTable_freeKey +#define CharHashTable_FREEVALUE(hashTable, key) \ + ((void) (hashTable), (void) (key)) #include "hashtable.h" Modified: trunk/sc2/src/libs/uio/gphys.h =================================================================== --- trunk/sc2/src/libs/uio/gphys.h 2011-12-16 21:01:55 UTC (rev 3702) +++ trunk/sc2/src/libs/uio/gphys.h 2011-12-20 20:16:17 UTC (rev 3703) @@ -33,7 +33,7 @@ #define uio_GPDirEntries_new() \ ((uio_GPDirEntries *) CharHashTable_newHashTable(NULL, NULL, NULL, \ - NULL, 0, 0.85, 0.9)) + NULL, NULL, 0, 0.85, 0.9)) #define uio_GPDirEntries_add(hashTable, name, item) \ CharHashTable_add((CharHashTable_HashTable *) hashTable, name, \ (void *) item) Modified: trunk/sc2/src/libs/uio/hashtable.c =================================================================== --- trunk/sc2/src/libs/uio/hashtable.c 2011-12-16 21:01:55 UTC (rev 3702) +++ trunk/sc2/src/libs/uio/hashtable.c 2011-12-20 20:16:17 UTC (rev 3703) @@ -46,12 +46,14 @@ static inline void HASHTABLE_(freeHashEntry)( HASHTABLE_(HashEntry) *entry); +// Create a new HashTable. HASHTABLE_(HashTable) * HASHTABLE_(newHashTable)( HASHTABLE_(HashFunction) hashFunction, HASHTABLE_(EqualFunction) equalFunction, HASHTABLE_(CopyFunction) copyFunction, - HASHTABLE_(FreeFunction) freeFunction, + HASHTABLE_(FreeKeyFunction) freeKeyFunction, + HASHTABLE_(FreeValueFunction) freeValueFunction, uio_uint32 initialSize, double minFillQuotient, double maxFillQuotient) { @@ -63,7 +65,8 @@ hashTable->hashFunction = hashFunction; hashTable->equalFunction = equalFunction; hashTable->copyFunction = copyFunction; - hashTable->freeFunction = freeFunction; + hashTable->freeKeyFunction = freeKeyFunction; + hashTable->freeValueFunction = freeValueFunction; hashTable->minFillQuotient = minFillQuotient; hashTable->maxFillQuotient = maxFillQuotient; @@ -72,6 +75,7 @@ return hashTable; } +// Add an entry to the HashTable. uio_bool HASHTABLE_(add)(HASHTABLE_(HashTable) *hashTable, const HASHTABLE_(Key) *key, HASHTABLE_(Value) *value) { @@ -104,6 +108,7 @@ return true; } +// Remove an entry with a specified Key from the HashTable. uio_bool HASHTABLE_(remove)(HASHTABLE_(HashTable) *hashTable, const HASHTABLE_(Key) *key) { @@ -122,7 +127,8 @@ entry = &(*entry)->next; } next = (*entry)->next; - HASHTABLE_(FREE)(hashTable, (*entry)->key); + HASHTABLE_(FREEKEY)(hashTable, (*entry)->key); + HASHTABLE_(FREEVALUE)(hashTable, (*entry)->value); HASHTABLE_(freeHashEntry)(*entry); *entry = next; @@ -133,6 +139,7 @@ return true; } +// Find the Value stored for some Key. HASHTABLE_(Value) * HASHTABLE_(find)(HASHTABLE_(HashTable) *hashTable, const HASHTABLE_(Key) *key) { @@ -151,11 +158,13 @@ return NULL; } +// Returns the number of entries in the HashTable. uio_uint32 HASHTABLE_(count)(const HASHTABLE_(HashTable) *hashTable) { return hashTable->numEntries; } +// Auxiliary function to (re)initialise the buckets in the HashTable. static void HASHTABLE_(setup)(HASHTABLE_(HashTable) *hashTable, uio_uint32 initialSize) { if (initialSize < 4) @@ -175,6 +184,7 @@ #endif } +// Resize the buckets in the HashTable. static void HASHTABLE_(resize)(HASHTABLE_(HashTable) *hashTable) { HASHTABLE_(HashEntry) **oldEntries; @@ -224,6 +234,7 @@ return x + 1; } +// Get an iterator to iterate through all the entries in the HashTable. // NB: Iterator should be considered invalid if the HashTable is changed. // TODO: change this (make it thread-safe) // this can be done by only marking items as deleted when @@ -252,21 +263,26 @@ return iterator; } +// Returns true if and only if there are no more entries in the hash table +// for the Iterator to find. int HASHTABLE_(iteratorDone)(const HASHTABLE_(Iterator) *iterator) { return iterator->bucketNr >= iterator->hashTable->size; } +// Get the Key of the entry pointed to by an Iterator. HASHTABLE_(Key) * HASHTABLE_(iteratorKey)(HASHTABLE_(Iterator) *iterator) { return iterator->entry->key; } +// Get the Value of the entry pointed to by an Iterator. HASHTABLE_(Value) * HASHTABLE_(iteratorValue)(HASHTABLE_(Iterator) *iterator) { return iterator->entry->value; } +// Move the Iterator to the next entry in the HashTable. // Should not be called if the iterator is already past the last entry. HASHTABLE_(Iterator) * HASHTABLE_(iteratorNext)(HASHTABLE_(Iterator) *iterator) { @@ -293,16 +309,19 @@ return iterator; } +// Free the Iterator. void HASHTABLE_(freeIterator)(HASHTABLE_(Iterator) *iterator) { uio_free(iterator); } +// Auxiliary function to allocate a HashTable. static inline HASHTABLE_(HashTable) * HASHTABLE_(allocHashTable)(void) { return uio_malloc(sizeof (HASHTABLE_(HashTable))); } +// Auxiliary function to create a HashEntry. static inline HASHTABLE_(HashEntry) * HASHTABLE_(newHashEntry)(uio_uint32 hash, HASHTABLE_(Key) *key, HASHTABLE_(Value) *value, HASHTABLE_(HashEntry) *next) { @@ -316,11 +335,13 @@ return result; } +// Allocate a new HashEntry. static inline HASHTABLE_(HashEntry) * HASHTABLE_(allocHashEntry)(void) { return uio_malloc(sizeof (HASHTABLE_(HashEntry))); } +// Delete the HashTable. void HASHTABLE_(deleteHashTable)(HASHTABLE_(HashTable) *hashTable) { uio_uint32 i; @@ -333,7 +354,8 @@ entry = *bucketPtr; while (entry != NULL) { next = entry->next; - HASHTABLE_(FREE)(hashTable, entry->key); + HASHTABLE_(FREEKEY)(hashTable, entry->key); + HASHTABLE_(FREEVALUE)(hashTable, entry->value); HASHTABLE_(freeHashEntry)(entry); entry = next; i--; @@ -344,6 +366,7 @@ uio_free(hashTable); } +// Auxiliary function to deallocate a HashEntry. static inline void HASHTABLE_(freeHashEntry)(HASHTABLE_(HashEntry) *entry) { uio_free(entry); Modified: trunk/sc2/src/libs/uio/hashtable.h =================================================================== --- trunk/sc2/src/libs/uio/hashtable.h 2011-12-16 21:01:55 UTC (rev 3702) +++ trunk/sc2/src/libs/uio/hashtable.h 2011-12-20 20:16:17 UTC (rev 3703) @@ -39,6 +39,8 @@ // (and typedefs) from the HASHTABLE_ block below. // In the .c file, #define HASHTABLE_INTERNAL, #include the .h file // and hashtable.c (in this order), and add the necessary functions. +// If you do not need to free the Value, you can define HashTable_FREEVALUE +// as a no-op. #ifndef HASHTABLE_ # define HASHTABLE_(identifier) HashTable ## _ ## identifier typedef void HashTable_Key; @@ -49,8 +51,10 @@ (hashTable)->equalFunction(hashKey1, hashKey2) # define HashTable_COPY(hashTable, hashKey) \ (hashTable)->copyFunction(hashKey) -# define HashTable_FREE(hashTable, hashKey) \ - (hashTable)->freeFunction(hashKey) +# define HashTable_FREEKEY(hashTable, hashKey) \ + (hashTable)->freeKeyFunction(hashKey) +# define HashTable_FREEVALUE(hashTable, hashValue) \ + (hashTable)->freeValueFunction(hashKey) #endif @@ -59,8 +63,9 @@ typedef uio_bool (*HASHTABLE_(EqualFunction))(const HASHTABLE_(Key) *, const HASHTABLE_(Key) *); typedef HASHTABLE_(Value) *(*HASHTABLE_(CopyFunction))( - const HASHTABLE_(Value) *); -typedef void (*HASHTABLE_(FreeFunction))(HASHTABLE_(Value) *); + const HASHTABLE_(Key) *); +typedef void (*HASHTABLE_(FreeKeyFunction))(HASHTABLE_(Key) *); +typedef void (*HASHTABLE_(FreeValueFunction))(HASHTABLE_(Value) *); typedef struct HASHTABLE_(HashTable) HASHTABLE_(HashTable); typedef struct HASHTABLE_(HashEntry) HASHTABLE_(HashEntry); @@ -68,9 +73,17 @@ struct HASHTABLE_(HashTable) { HASHTABLE_(HashFunction) hashFunction; + // Function creating a uio_uint32 hash of a key. HASHTABLE_(EqualFunction) equalFunction; + // Function used to compare two keys. HASHTABLE_(CopyFunction) copyFunction; - HASHTABLE_(FreeFunction) freeFunction; + // Function used to copy a key. + HASHTABLE_(FreeKeyFunction) freeKeyFunction; + // Function used to free a key. + HASHTABLE_(FreeValueFunction) freeValueFunction; + // Function used to free a value. Called when an entry is + // removed using the remove function, or for entries + // still in the HashTable when the HashTable is deleted. double minFillQuotient; // How much of half of the hashtable needs to be filled @@ -114,7 +127,9 @@ HASHTABLE_(HashFunction) hashFunction, HASHTABLE_(EqualFunction) equalFunction, HASHTABLE_(CopyFunction) copyFunction, - HASHTABLE_(FreeFunction) freeFunction, uio_uint32 initialSize, + HASHTABLE_(FreeKeyFunction) freeKeyFunction, + HASHTABLE_(FreeValueFunction) freeValueFunction, + uio_uint32 initialSize, double minFillQuotient, double maxFillQuotient); uio_bool HASHTABLE_(add)(HASHTABLE_(HashTable) *hashTable, const HASHTABLE_(Key) *key, HASHTABLE_(Value) *value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-12-16 21:02:03
|
Revision: 3702 http://sc2.svn.sourceforge.net/sc2/?rev=3702&view=rev Author: Meep-Eep Date: 2011-12-16 21:01:55 +0000 (Fri, 16 Dec 2011) Log Message: ----------- Annihigate ActivateStarShip(). Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/build.c trunk/sc2/src/uqm/build.h trunk/sc2/src/uqm/comm/chmmr/chmmrc.c trunk/sc2/src/uqm/comm/druuge/druugec.c trunk/sc2/src/uqm/comm/orz/orzc.c trunk/sc2/src/uqm/comm/pkunk/pkunkc.c trunk/sc2/src/uqm/comm/rebel/rebel.c trunk/sc2/src/uqm/comm/spahome/spahome.c trunk/sc2/src/uqm/comm/spathi/spathic.c trunk/sc2/src/uqm/comm/starbas/starbas.c trunk/sc2/src/uqm/comm/supox/supoxc.c trunk/sc2/src/uqm/comm/syreen/syreenc.c trunk/sc2/src/uqm/comm/talkpet/talkpet.c trunk/sc2/src/uqm/comm/thradd/thraddc.c trunk/sc2/src/uqm/comm/umgah/umgahc.c trunk/sc2/src/uqm/comm/utwig/utwigc.c trunk/sc2/src/uqm/comm/yehat/yehatc.c trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/gameev.c trunk/sc2/src/uqm/globdata.c trunk/sc2/src/uqm/planets/devices.c trunk/sc2/src/uqm/planets/generate/genchmmr.c trunk/sc2/src/uqm/planets/generate/gendru.c trunk/sc2/src/uqm/planets/generate/genilw.c trunk/sc2/src/uqm/planets/generate/genmyc.c trunk/sc2/src/uqm/planets/generate/genorz.c trunk/sc2/src/uqm/planets/generate/genpet.c trunk/sc2/src/uqm/planets/generate/genpku.c trunk/sc2/src/uqm/planets/generate/gensam.c trunk/sc2/src/uqm/planets/generate/genspa.c trunk/sc2/src/uqm/planets/generate/gensup.c trunk/sc2/src/uqm/planets/generate/genthrad.c trunk/sc2/src/uqm/planets/generate/genutw.c trunk/sc2/src/uqm/planets/generate/genvux.c trunk/sc2/src/uqm/planets/generate/genyeh.c trunk/sc2/src/uqm/planets/generate/genzoq.c trunk/sc2/src/uqm/races.h trunk/sc2/src/uqm/shipyard.c trunk/sc2/src/uqm/uqmdebug.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/ChangeLog 2011-12-16 21:01:55 UTC (rev 3702) @@ -1,5 +1,6 @@ Changes towards version 0.8: -- Removed obsolete RESPONSE_TO_REF - SvdB +- Annigilate ActivateStarShip() - SvdB +- Removed obsolete RESPONSE_TO_REF() - SvdB - Don't require the 'shadow' dir in addon packs, from Alex - Make use of GAME_STATE_FILE consistently, from Scott A. Colcord - Fixed unconst(), from Scott A. Colcord Modified: trunk/sc2/src/uqm/build.c =================================================================== --- trunk/sc2/src/uqm/build.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/build.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -69,232 +69,287 @@ } /* - * What this function does depends on the value of the 'state' argument: - * SPHERE_TRACKING: - * The sphere of influence for the race for 'which_ship' will be shown - * on the starmap in the future. - * The value returned is 'which_ship', unless the type of ship is only - * available in SuperMelee, in which case 0 is returned. - * SPHERE_KNOWN: - * The size of the fleet of the race of 'which_ship' when the starmap was - * last checked is returned. - * ESCORT_WORTH: - * The total value of all the ships escorting the SIS is returned. - * 'which_ship' is ignored. - * ESCORTING_FLAGSHIP: - * Test if a ship of type 'which_ship' is among the escorts of the SIS - * 0 is returned if false, 1 if true. - * FEASIBILITY_STUDY: - * Test if the SIS can have an escort of type 'which_ship'. - * 0 is returned if 'which_ship' is not available. - * Otherwise, the number of ships that can be added is returned. - * CHECK_ALLIANCE: - * Test the alliance status of the race of 'which_ship'. - * Either GOOD_GUY (allied) or BAD_GUY (not allied) is returned. - * SET_ALLIED (0): - * Ally with the race of 'which_ship'. This makes their ship available - * for building in the shipyard. - * SET_NOT_ALLIED: - * End an alliance with the race of 'which_ship'. This ends the possibility - * of building their ships in the shipyard. - * REMOVE_BUILT: - * Make the already built escorts of the race of 'which_ship' disappear. - * (as for the Orz when the alliance with them ends) - * any other positive number: - * Give the player this many ships of type 'which_ship'. + * Give the player 'count' ships of the specified race, + * limited by the number of free slots. + * Returns the number of ships added. */ COUNT -ActivateStarShip (COUNT which_ship, SIZE state) +AddEscortShips (COUNT race, SIZE count) { HFLEETINFO hFleet; + BYTE which_window; + COUNT i; - hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), which_ship); + hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race); if (!hFleet) return 0; - switch (state) + assert (count > 0); + + which_window = 0; + for (i = 0; i < (COUNT) count; i++) { - case SPHERE_TRACKING: - case SPHERE_KNOWN: + HSHIPFRAG hStarShip; + HSHIPFRAG hOldShip; + SHIP_FRAGMENT *StarShipPtr; + + hStarShip = CloneShipFragment (race, &GLOBAL (built_ship_q), 0); + if (!hStarShip) + break; + + RemoveQueue (&GLOBAL (built_ship_q), hStarShip); + + /* Find first available escort window */ + while ((hOldShip = GetStarShipFromIndex ( + &GLOBAL (built_ship_q), which_window++))) { - FLEET_INFO *FleetPtr; + BYTE win_loc; - FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hFleet); - if (state == SPHERE_KNOWN) - which_ship = FleetPtr->known_strength; - else if (FleetPtr->actual_strength == 0) - { - if (FleetPtr->allied_state == DEAD_GUY) - which_ship = 0; - } - else if (FleetPtr->known_strength == 0 - && FleetPtr->actual_strength != INFINITE_RADIUS) - { - FleetPtr->known_strength = 1; - FleetPtr->known_loc = FleetPtr->loc; - } - UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); - return (which_ship); + StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hOldShip); + win_loc = StarShipPtr->index; + UnlockShipFrag (&GLOBAL (built_ship_q), hOldShip); + if (which_window <= win_loc) + break; } - case ESCORT_WORTH: - { - COUNT ShipCost[] = - { - RACE_SHIP_COST - }; - COUNT total = 0; - HSHIPFRAG hStarShip, hNextShip; - for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); - hStarShip; hStarShip = hNextShip) - { - SHIP_FRAGMENT *StarShipPtr; + StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip); + StarShipPtr->index = which_window - 1; + UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); - StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip); - hNextShip = _GetSuccLink (StarShipPtr); - total += ShipCost[StarShipPtr->race_id]; - UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); - } - return total; - } - case ESCORTING_FLAGSHIP: - { - HSHIPFRAG hStarShip, hNextShip; + InsertQueue (&GLOBAL (built_ship_q), hStarShip, hOldShip); + } - for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); - hStarShip; hStarShip = hNextShip) - { - BYTE ship_type; - SHIP_FRAGMENT *StarShipPtr; + LockMutex (GraphicsLock); + DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA); + UnlockMutex (GraphicsLock); + return i; +} - StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip); - hNextShip = _GetSuccLink (StarShipPtr); - ship_type = StarShipPtr->race_id; - UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); +/* + * Returns the total value of all the ships escorting the SIS. + */ +COUNT +CalculateEscortsWorth (void) +{ + COUNT ShipCost[] = + { + RACE_SHIP_COST + }; + COUNT total = 0; + HSHIPFRAG hStarShip, hNextShip; - if (ship_type == which_ship) - return 1; - } - return 0; - } - case FEASIBILITY_STUDY: + for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); + hStarShip; hStarShip = hNextShip) + { + SHIP_FRAGMENT *StarShipPtr; + + StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip); + hNextShip = _GetSuccLink (StarShipPtr); + total += ShipCost[StarShipPtr->race_id]; + UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); + } + return total; +} + +#if 0 +/* + * Returns the size of the fleet of the specified race when the starmap was + * last checked. If the race has no SoI, 0 is returned. + */ +COUNT +GetRaceKnownSize (COUNT race) +{ + HFLEETINFO hFleet; + FLEET_INFO *FleetPtr; + COUNT result; + + hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race); + if (!hFleet) + return 0; + + FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hFleet); + + result = FleetPtr->known_strength; + + UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); + return result; +} +#endif + +/* + * Start or end an alliance with the specified race. + * Being in an alliance with a race makes their ships available for building + * in the shipyard. + * flag == TRUE: start an alliance + * flag == TRUE: end an alliance + */ +COUNT +SetRaceAllied (COUNT race, BOOLEAN flag) { + HFLEETINFO hFleet; + FLEET_INFO *FleetPtr; + + hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race); + if (!hFleet) + return 0; + + FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hFleet); + + if (FleetPtr->allied_state == DEAD_GUY) + { + /* Strange request, silently ignore it */ + } + else + { + FleetPtr->allied_state = (flag ? GOOD_GUY : BAD_GUY); + } + + UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); + return 1; +} + +/* + * Make the sphere of influence for the specified race shown on the starmap + * in the future. + * The value returned is 'race', unless the type of ship is only available + * in SuperMelee, in which case 0 is returned. + */ +COUNT +StartSphereTracking (COUNT race) +{ + HFLEETINFO hFleet; + FLEET_INFO *FleetPtr; + + hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race); + if (!hFleet) + return 0; + + FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hFleet); + + if (FleetPtr->actual_strength == 0) + { + if (FleetPtr->allied_state == DEAD_GUY) { - return (MAX_BUILT_SHIPS - CountLinks (&GLOBAL (built_ship_q))); - } - case CHECK_ALLIANCE: - { - UWORD flags; - FLEET_INFO *FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), - hFleet); - flags = FleetPtr->allied_state; + // Race is extinct. UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); - return flags; + return 0; } - case SET_ALLIED: - case SET_NOT_ALLIED: - { - FLEET_INFO *FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), - hFleet); + } + else if (FleetPtr->known_strength == 0 + && FleetPtr->actual_strength != INFINITE_RADIUS) + { + FleetPtr->known_strength = 1; + FleetPtr->known_loc = FleetPtr->loc; + } - if (FleetPtr->allied_state == DEAD_GUY) - { /* Strange request, silently ignore it */ - UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); - break; - } + UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); + return race; +} - if (state == SET_ALLIED) - FleetPtr->allied_state = GOOD_GUY; - else - FleetPtr->allied_state = BAD_GUY; - - UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); - break; - } - case REMOVE_BUILT: - { - HSHIPFRAG hStarShip, hNextShip; - BOOLEAN ShipRemoved = FALSE; +/* + * Returns true if and only if a ship of the specified race is among the + * escort ships. + */ +BOOLEAN +HaveEscortShip (COUNT race) +{ + HFLEETINFO hFleet; + HSHIPFRAG hStarShip, hNextShip; - for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); - hStarShip; hStarShip = hNextShip) - { - BOOLEAN RemoveShip; - SHIP_FRAGMENT *StarShipPtr; + hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race); + if (!hFleet) + return FALSE; - StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip); - hNextShip = _GetSuccLink (StarShipPtr); - RemoveShip = (StarShipPtr->race_id == which_ship); - UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); + for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip; + hStarShip = hNextShip) + { + BYTE ship_type; + SHIP_FRAGMENT *StarShipPtr; - if (RemoveShip) - { - ShipRemoved = TRUE; + StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip); + hNextShip = _GetSuccLink (StarShipPtr); + ship_type = StarShipPtr->race_id; + UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); - RemoveQueue (&GLOBAL (built_ship_q), hStarShip); - FreeShipFrag (&GLOBAL (built_ship_q), hStarShip); - } - } - - if (ShipRemoved) - { - LockMutex (GraphicsLock); - DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, - UNDEFINED_DELTA); - UnlockMutex (GraphicsLock); - } - break; - } - default: - { - BYTE which_window; - COUNT i; + if (ship_type == race) + return TRUE; + } + return FALSE; +} - assert (state > 0); - /* Add ships to the escorts */ - which_window = 0; - for (i = 0; i < (COUNT)state; i++) - { - HSHIPFRAG hStarShip; - HSHIPFRAG hOldShip; - SHIP_FRAGMENT *StarShipPtr; +/* + * Test if the SIS can have an escort of the specified race. + * Returns 0 if 'race' is not available. + * Otherwise, returns the number of ships that can be added. + */ +COUNT +EscortFeasibilityStudy (COUNT race) +{ + HFLEETINFO hFleet; - hStarShip = CloneShipFragment (which_ship, - &GLOBAL (built_ship_q), 0); - if (!hStarShip) - break; + hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race); + if (!hFleet) + return 0; - RemoveQueue (&GLOBAL (built_ship_q), hStarShip); + return (MAX_BUILT_SHIPS - CountLinks (&GLOBAL (built_ship_q))); +} - /* Find first available escort window */ - while ((hOldShip = GetStarShipFromIndex ( - &GLOBAL (built_ship_q), which_window++))) - { - BYTE win_loc; +/* + * Test the alliance status of the specified race. + * Either DEAD_GUY (extinct), GOOD_GUY (allied), or BAD_GUY (not allied) is + * returned. + */ +COUNT +CheckAlliance (COUNT race) +{ + HFLEETINFO hFleet; + UWORD flags; + FLEET_INFO *FleetPtr; - StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), - hOldShip); - win_loc = StarShipPtr->index; - UnlockShipFrag (&GLOBAL (built_ship_q), hOldShip); - if (which_window <= win_loc) - break; - } + hFleet = GetStarShipFromIndex (&GLOBAL (avail_race_q), race); + if (!hFleet) + return 0; - StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip); - StarShipPtr->index = which_window - 1; - UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); + FleetPtr = LockFleetInfo (&GLOBAL (avail_race_q), hFleet); + flags = FleetPtr->allied_state; + UnlockFleetInfo (&GLOBAL (avail_race_q), hFleet); - InsertQueue (&GLOBAL (built_ship_q), hStarShip, hOldShip); - } + return flags; +} - LockMutex (GraphicsLock); - DeltaSISGauges (UNDEFINED_DELTA, - UNDEFINED_DELTA, UNDEFINED_DELTA); - UnlockMutex (GraphicsLock); - return i; +/* + * Remove all escort ships of the specified race. + */ +void +RemoveEscortShips (COUNT race) +{ + HSHIPFRAG hStarShip, hNextShip; + BOOLEAN ShipRemoved = FALSE; + + for (hStarShip = GetHeadLink (&GLOBAL (built_ship_q)); hStarShip; + hStarShip = hNextShip) + { + BOOLEAN RemoveShip; + SHIP_FRAGMENT *StarShipPtr; + + StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q), hStarShip); + hNextShip = _GetSuccLink (StarShipPtr); + RemoveShip = (StarShipPtr->race_id == race); + UnlockShipFrag (&GLOBAL (built_ship_q), hStarShip); + + if (RemoveShip) + { + ShipRemoved = TRUE; + RemoveQueue (&GLOBAL (built_ship_q), hStarShip); + FreeShipFrag (&GLOBAL (built_ship_q), hStarShip); } } - - return 1; + + if (ShipRemoved) + { + LockMutex (GraphicsLock); + DeltaSISGauges (UNDEFINED_DELTA, UNDEFINED_DELTA, UNDEFINED_DELTA); + UnlockMutex (GraphicsLock); + } } COUNT Modified: trunk/sc2/src/uqm/build.h =================================================================== --- trunk/sc2/src/uqm/build.h 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/build.h 2011-12-16 21:01:55 UTC (rev 3702) @@ -60,6 +60,16 @@ extern int SetEscortCrewComplement (COUNT which_ship, COUNT crew_level, BYTE captain); +COUNT AddEscortShips (COUNT race, SIZE count); +extern COUNT CalculateEscortsWorth (void); +//extern COUNT GetRaceKnownSize (COUNT race); +extern COUNT SetRaceAllied (COUNT race, BOOLEAN flag); +extern COUNT StartSphereTracking (COUNT race); +BOOLEAN HaveEscortShip (COUNT race); +extern COUNT EscortFeasibilityStudy (COUNT race); +extern COUNT CheckAlliance (COUNT race); +extern void RemoveEscortShips (COUNT race); + extern RACE_DESC *load_ship (SPECIES_ID SpeciesID, BOOLEAN LoadBattleData); extern void free_ship (RACE_DESC *RaceDescPtr, BOOLEAN FreeIconData, BOOLEAN FreeBattleData); Modified: trunk/sc2/src/uqm/comm/chmmr/chmmrc.c =================================================================== --- trunk/sc2/src/uqm/comm/chmmr/chmmrc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/chmmr/chmmrc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -134,7 +134,7 @@ NPCPhrase (TAKE_2_WEEKS); - ActivateStarShip (CHMMR_SHIP, SET_ALLIED); + SetRaceAllied (CHMMR_SHIP, TRUE); SET_GAME_STATE (CHMMR_HOME_VISITS, 0); SET_GAME_STATE (CHMMR_STACK, 0); @@ -248,7 +248,7 @@ { NPCPhrase (USE_OUR_SHIPS_BEFORE); - ActivateStarShip (CHMMR_SHIP, SET_ALLIED); + SetRaceAllied (CHMMR_SHIP, TRUE); } else if (PLAYER_SAID (R, where_weapon)) { @@ -263,7 +263,7 @@ DISABLE_PHRASE (where_distraction); } - if (ActivateStarShip (CHMMR_SHIP, CHECK_ALLIANCE) != GOOD_GUY) + if (CheckAlliance (CHMMR_SHIP) != GOOD_GUY) Response (tech_help, NotReady); else if (PHRASE_ENABLED (further_assistance)) Response (further_assistance, NotReady); @@ -301,7 +301,7 @@ { NPCPhrase (USE_OUR_SHIPS_AFTER); - ActivateStarShip (CHMMR_SHIP, SET_ALLIED); + SetRaceAllied (CHMMR_SHIP, TRUE); } if (PHRASE_ENABLED (what_now)) @@ -310,7 +310,7 @@ Response (wont_hurt_my_ship, ImproveBomb); else if (PHRASE_ENABLED (bummer_about_my_ship)) Response (bummer_about_my_ship, ImproveBomb); - if (ActivateStarShip (CHMMR_SHIP, CHECK_ALLIANCE) != GOOD_GUY) + if (CheckAlliance (CHMMR_SHIP) != GOOD_GUY) Response (other_assistance, ImproveBomb); Response (proceed, ExitConversation); } Modified: trunk/sc2/src/uqm/comm/druuge/druugec.c =================================================================== --- trunk/sc2/src/uqm/comm/druuge/druugec.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/druuge/druugec.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -240,7 +240,7 @@ #define SHIP_CREW_COST 100 if (GLOBAL_SIS (CrewEnlisted) < SHIP_CREW_COST) NPCPhrase (NOT_ENOUGH_CREW); - else if (ActivateStarShip (DRUUGE_SHIP, FEASIBILITY_STUDY) == 0) + else if (EscortFeasibilityStudy (DRUUGE_SHIP) == 0) NPCPhrase (NOT_ENOUGH_ROOM); else { @@ -248,7 +248,7 @@ DeltaSISGauges (-SHIP_CREW_COST, 0, 0); UnlockMutex (GraphicsLock); SlaveryCount += SHIP_CREW_COST; - ActivateStarShip (DRUUGE_SHIP, 1); + AddEscortShips (DRUUGE_SHIP, 1); NPCPhrase (BOUGHT_SHIP); } @@ -403,7 +403,7 @@ trade_gas = 0; ships_to_trade = 0; - ship_slots = ActivateStarShip (DRUUGE_SHIP, FEASIBILITY_STUDY); + ship_slots = EscortFeasibilityStudy (DRUUGE_SHIP); if (PLAYER_SAID (R, sell_maidens)) { NPCPhrase (BOUGHT_MAIDENS); @@ -430,7 +430,7 @@ NPCPhrase (YOU_GET); if (ships_to_trade) { - ActivateStarShip (DRUUGE_SHIP, ships_to_trade); + AddEscortShips (DRUUGE_SHIP, ships_to_trade); if (ship_slots >= ships_to_trade) NPCPhrase (DEAL_FOR_STATED_SHIPS); Modified: trunk/sc2/src/uqm/comm/orz/orzc.c =================================================================== --- trunk/sc2/src/uqm/comm/orz/orzc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/orz/orzc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -213,7 +213,7 @@ SET_GAME_STATE (ORZ_GENERAL_INFO, 0); SET_GAME_STATE (ORZ_PERSONAL_INFO, 0); SET_GAME_STATE (ORZ_MANNER, 3); - ActivateStarShip (ORZ_SHIP, SET_ALLIED); + SetRaceAllied (ORZ_SHIP, TRUE); } else if (PLAYER_SAID (R, demand_to_land)) { @@ -234,8 +234,8 @@ SET_GAME_STATE (BATTLE_SEGUE, 1); if (PLAYER_SAID (R, about_andro_3)) { - ActivateStarShip (ORZ_SHIP, SET_NOT_ALLIED); - ActivateStarShip (ORZ_SHIP, REMOVE_BUILT); + SetRaceAllied (ORZ_SHIP, FALSE); + RemoveEscortShips (ORZ_SHIP); } XFormColorMap (GetColorMapAddress ( @@ -322,8 +322,7 @@ if (PHRASE_ENABLED (may_we_land)) { - if (Manner == 3 && - ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE) == GOOD_GUY) + if (Manner == 3 && CheckAlliance (ORZ_SHIP) == GOOD_GUY) Response (may_we_land, ExitConversation); else Response (may_we_land, TaaloWorld); @@ -705,8 +704,7 @@ TaaloWorld ((RESPONSE_REF)0); } - else if (Manner == 3 && - ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE) == GOOD_GUY) + else if (Manner == 3 && CheckAlliance (ORZ_SHIP) == GOOD_GUY) { if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7)) { Modified: trunk/sc2/src/uqm/comm/pkunk/pkunkc.c =================================================================== --- trunk/sc2/src/uqm/comm/pkunk/pkunkc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/pkunk/pkunkc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -110,7 +110,7 @@ PrepareShip (void) { #define MAX_PKUNK_SHIPS 4 - if (ActivateStarShip (PKUNK_SHIP, MAX_PKUNK_SHIPS)) + if (AddEscortShips (PKUNK_SHIP, MAX_PKUNK_SHIPS)) { BYTE mi, di, yi; @@ -157,7 +157,7 @@ SET_GAME_STATE (PKUNK_INFO, 0); AddEvent (RELATIVE_EVENT, 6, 0, 0, ADVANCE_PKUNK_MISSION); - if (ActivateStarShip (PKUNK_SHIP, FEASIBILITY_STUDY) == 0) + if (EscortFeasibilityStudy (PKUNK_SHIP) == 0) NPCPhrase (INIT_NO_ROOM); else { @@ -949,7 +949,7 @@ { if (NumVisits && ShipsReady ()) { - if (ActivateStarShip (PKUNK_SHIP, FEASIBILITY_STUDY) == 0) + if (EscortFeasibilityStudy (PKUNK_SHIP) == 0) NPCPhrase (NO_ROOM); else { Modified: trunk/sc2/src/uqm/comm/rebel/rebel.c =================================================================== --- trunk/sc2/src/uqm/comm/rebel/rebel.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/rebel/rebel.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -324,7 +324,7 @@ || ((NumVisits == 0 && (NumVisits = GLOBAL (GameClock.month_index) - GET_GAME_STATE (YEHAT_SHIP_MONTH)) < 0) || (NumVisits == 0 && GLOBAL (GameClock.day_index) < GET_GAME_STATE (YEHAT_SHIP_DAY))))) NPCPhrase (NO_SHIPS_YET); - else if ((NumVisits = ActivateStarShip (YEHAT_SHIP, FEASIBILITY_STUDY)) == 0) + else if ((NumVisits = EscortFeasibilityStudy (YEHAT_SHIP)) == 0) NPCPhrase (NO_ROOM); else { @@ -338,7 +338,7 @@ } AlienTalkSegue ((COUNT)~0); - ActivateStarShip (YEHAT_SHIP, NumVisits); + AddEscortShips (YEHAT_SHIP, NumVisits); PrepareShip (); } @@ -382,12 +382,11 @@ NPCPhrase (YEHAT_CAVALRY); AlienTalkSegue ((COUNT)~0); - if ((NumVisits = (BYTE)ActivateStarShip ( - YEHAT_REBEL_SHIP, FEASIBILITY_STUDY - )) > 8) + NumVisits = (BYTE) EscortFeasibilityStudy (YEHAT_REBEL_SHIP); + if (NumVisits > 8) NumVisits = 8; - ActivateStarShip (YEHAT_REBEL_SHIP, NumVisits - (NumVisits >> 1)); - ActivateStarShip (PKUNK_SHIP, NumVisits >> 1); + AddEscortShips (YEHAT_REBEL_SHIP, NumVisits - (NumVisits >> 1)); + AddEscortShips (PKUNK_SHIP, NumVisits >> 1); } else { Modified: trunk/sc2/src/uqm/comm/spahome/spahome.c =================================================================== --- trunk/sc2/src/uqm/comm/spahome/spahome.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/spahome/spahome.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -251,7 +251,7 @@ { NPCPhrase (DEPART_FOR_EARTH); - ActivateStarShip (SPATHI_SHIP, SET_ALLIED); + SetRaceAllied (SPATHI_SHIP, TRUE); AddEvent (RELATIVE_EVENT, 6, 0, 0, SPATHI_SHIELD_EVENT); SET_GAME_STATE (SPATHI_HOME_VISITS, 0); SET_GAME_STATE (SPATHI_VISITS, 0); @@ -821,7 +821,7 @@ { if (PHRASE_ENABLED (spathi_on_pluto)) Response (spathi_on_pluto, SpathiCouncil); - else if (ActivateStarShip (SPATHI_SHIP, ESCORTING_FLAGSHIP)) + else if (HaveEscortShip (SPATHI_SHIP)) { if (PHRASE_ENABLED (hostage)) Response (hostage, SpathiCouncil); @@ -915,7 +915,7 @@ { SpathiAngry ((RESPONSE_REF)0); } - else if (ActivateStarShip (SPATHI_SHIP, CHECK_ALLIANCE) == GOOD_GUY) + else if (CheckAlliance (SPATHI_SHIP) == GOOD_GUY) { CommData.AlienColorMap = SetAbsColorMapIndex (CommData.AlienColorMap, 1); Modified: trunk/sc2/src/uqm/comm/spathi/spathic.c =================================================================== --- trunk/sc2/src/uqm/comm/spathi/spathic.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/spathi/spathic.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -188,14 +188,14 @@ } else if (PLAYER_SAID (Response, join_us)) { - if (ActivateStarShip (SPATHI_SHIP, FEASIBILITY_STUDY) == 0) + if (EscortFeasibilityStudy (SPATHI_SHIP) == 0) NPCPhrase (TOO_SCARY); else { NPCPhrase (WILL_JOIN); AlienTalkSegue ((COUNT)~0); - ActivateStarShip (SPATHI_SHIP, 1); + AddEscortShips (SPATHI_SHIP, 1); /* Make the Eluder escort captained by Fwiffo alone */ SetEscortCrewComplement (SPATHI_SHIP, 1, NAME_OFFSET + NUM_CAPTAINS_NAMES); @@ -750,7 +750,7 @@ Response (we_fight_again_space, ExitConversation); Response (bye_angry_space, ExitConversation); } - else if (ActivateStarShip (SPATHI_SHIP, CHECK_ALLIANCE) == GOOD_GUY) + else if (CheckAlliance (SPATHI_SHIP) == GOOD_GUY) { SpathiAllies ((RESPONSE_REF)0); } Modified: trunk/sc2/src/uqm/comm/starbas/starbas.c =================================================================== --- trunk/sc2/src/uqm/comm/starbas/starbas.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/starbas/starbas.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -700,11 +700,10 @@ COUNT FleetStrength; BOOLEAN HasMaximum; - FleetStrength = ActivateStarShip (0, ESCORT_WORTH); + FleetStrength = CalculateEscortsWorth (); for (i = 0; i < NUM_AVAILABLE_RACES; ++i) { - if (i != HUMAN_SHIP - && ActivateStarShip (i, CHECK_ALLIANCE) == GOOD_GUY) + if (i != HUMAN_SHIP && CheckAlliance (i) == GOOD_GUY) ++num_aliens; } @@ -1377,36 +1376,31 @@ switch (b0) { case 0: - if (ActivateStarShip (SPATHI_SHIP, CHECK_ALLIANCE) - == GOOD_GUY) + if (CheckAlliance (SPATHI_SHIP) == GOOD_GUY) { pStr = STARBASE_BULLETIN_1; } break; case 1: - if (ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) - == GOOD_GUY) + if (CheckAlliance (ZOQFOTPIK_SHIP) == GOOD_GUY) { pStr = STARBASE_BULLETIN_2; } break; case 2: - if (ActivateStarShip (SUPOX_SHIP, CHECK_ALLIANCE) - == GOOD_GUY) + if (CheckAlliance (SUPOX_SHIP) == GOOD_GUY) { pStr = STARBASE_BULLETIN_3; } break; case 3: - if (ActivateStarShip (UTWIG_SHIP, CHECK_ALLIANCE) - == GOOD_GUY) + if (CheckAlliance (UTWIG_SHIP) == GOOD_GUY) { pStr = STARBASE_BULLETIN_4; } break; case 4: - if (ActivateStarShip (ORZ_SHIP, CHECK_ALLIANCE) - == GOOD_GUY) + if (CheckAlliance (ORZ_SHIP) == GOOD_GUY) { pStr = STARBASE_BULLETIN_5; } @@ -1415,14 +1409,13 @@ if (GET_GAME_STATE (ARILOU_MANNER) == 2) BulletinMask |= 1L << b0; else if (GET_GAME_STATE (PORTAL_SPAWNER) - && (Repeat || ActivateStarShip ( - ARILOU_SHIP, FEASIBILITY_STUDY - ))) + && (Repeat || EscortFeasibilityStudy ( + ARILOU_SHIP))) { #define NUM_GIFT_ARILOUS 3 pStr = STARBASE_BULLETIN_6; if (!Repeat) - ActivateStarShip (ARILOU_SHIP, NUM_GIFT_ARILOUS); + AddEscortShips (ARILOU_SHIP, NUM_GIFT_ARILOUS); } break; case 6: @@ -1471,15 +1464,13 @@ } break; case 12: - if (ActivateStarShip (CHMMR_SHIP, CHECK_ALLIANCE) - == GOOD_GUY) + if (CheckAlliance (CHMMR_SHIP) == GOOD_GUY) { pStr = STARBASE_BULLETIN_13; } break; case 13: - if (ActivateStarShip (SHOFIXTI_SHIP, CHECK_ALLIANCE) - == GOOD_GUY) + if (CheckAlliance (SHOFIXTI_SHIP) == GOOD_GUY) { pStr = STARBASE_BULLETIN_14; } Modified: trunk/sc2/src/uqm/comm/supox/supoxc.c =================================================================== --- trunk/sc2/src/uqm/comm/supox/supoxc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/supox/supoxc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -126,14 +126,14 @@ else if (PLAYER_SAID (R, can_you_help)) { NPCPhrase (HOW_HELP); - if (ActivateStarShip (SUPOX_SHIP, FEASIBILITY_STUDY) == 0) + if (EscortFeasibilityStudy (SUPOX_SHIP) == 0) NPCPhrase (DONT_NEED); else { NPCPhrase (HAVE_4_SHIPS); AlienTalkSegue ((COUNT)~0); - ActivateStarShip (SUPOX_SHIP, 4); + AddEscortShips (SUPOX_SHIP, 4); } } } @@ -357,7 +357,7 @@ LastStack = 2; SET_GAME_STATE (SUPOX_WAR_NEWS, 1); - ActivateStarShip (UTWIG_SHIP, SPHERE_TRACKING); + StartSphereTracking (UTWIG_SHIP); } else if (PLAYER_SAID (R, what_relation_to_utwig)) { @@ -552,7 +552,7 @@ SET_GAME_STATE (BATTLE_SEGUE, 0); } - else if (ActivateStarShip (SUPOX_SHIP, CHECK_ALLIANCE) == GOOD_GUY) + else if (CheckAlliance (SUPOX_SHIP) == GOOD_GUY) { if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7)) { Modified: trunk/sc2/src/uqm/comm/syreen/syreenc.c =================================================================== --- trunk/sc2/src/uqm/comm/syreen/syreenc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/syreen/syreenc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -740,7 +740,7 @@ { case 0: NPCPhrase (HELLO_AFTER_AMBUSH_1); - ActivateStarShip (SYREEN_SHIP, SET_ALLIED); + SetRaceAllied (SYREEN_SHIP, TRUE); break; case 1: NPCPhrase (HELLO_AFTER_AMBUSH_2); Modified: trunk/sc2/src/uqm/comm/talkpet/talkpet.c =================================================================== --- trunk/sc2/src/uqm/comm/talkpet/talkpet.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/talkpet/talkpet.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -780,7 +780,7 @@ } else { - if (ActivateStarShip (UMGAH_SHIP, SPHERE_TRACKING)) + if (StartSphereTracking (UMGAH_SHIP)) { NPCPhrase (LETS_MAKE_A_DEAL); } Modified: trunk/sc2/src/uqm/comm/thradd/thraddc.c =================================================================== --- trunk/sc2/src/uqm/comm/thradd/thraddc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/thradd/thraddc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -505,7 +505,7 @@ SET_GAME_STATE (THRADD_VISITS, 0); SET_GAME_STATE (THRADD_MANNER, 1); SET_GAME_STATE (THRADD_STACK_1, 0); - ActivateStarShip (THRADDASH_SHIP, SET_ALLIED); + SetRaceAllied (THRADDASH_SHIP, TRUE); Response (be_polite, ThraddCulture); Response (speak_pig_latin, ThraddCulture); Modified: trunk/sc2/src/uqm/comm/umgah/umgahc.c =================================================================== --- trunk/sc2/src/uqm/comm/umgah/umgahc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/umgah/umgahc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -242,7 +242,7 @@ NPCPhrase (FUNNY_IDEA); AlienTalkSegue ((COUNT)~0); - ActivateStarShip (UMGAH_SHIP, 4); + AddEscortShips (UMGAH_SHIP, 4); SET_GAME_STATE (UMGAH_HOSTILE, 1); } } Modified: trunk/sc2/src/uqm/comm/utwig/utwigc.c =================================================================== --- trunk/sc2/src/uqm/comm/utwig/utwigc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/utwig/utwigc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -288,22 +288,22 @@ SET_GAME_STATE (SUPOX_HOSTILE, 0); SET_GAME_STATE (UTWIG_HOSTILE, 0); - ActivateStarShip (UTWIG_SHIP, SET_ALLIED); - ActivateStarShip (SUPOX_SHIP, SET_ALLIED); + SetRaceAllied (UTWIG_SHIP, TRUE); + SetRaceAllied (SUPOX_SHIP, TRUE); } } } else if (PLAYER_SAID (R, can_you_help)) { NPCPhrase (HOW_HELP); - if (ActivateStarShip (UTWIG_SHIP, FEASIBILITY_STUDY) == 0) + if (EscortFeasibilityStudy (UTWIG_SHIP) == 0) NPCPhrase (DONT_NEED); else { NPCPhrase (HAVE_4_SHIPS); AlienTalkSegue ((COUNT)~0); - ActivateStarShip (UTWIG_SHIP, 4); + AddEscortShips (UTWIG_SHIP, 4); } } } @@ -390,7 +390,7 @@ Response (what_now_homeworld, AlliedHome); if (PHRASE_ENABLED (how_is_ultron)) Response (how_is_ultron, AlliedHome); - if (NumVisits == 0 && ActivateStarShip (UTWIG_SHIP, FEASIBILITY_STUDY) != 0) + if (NumVisits == 0 && EscortFeasibilityStudy (UTWIG_SHIP) != 0) Response (can_you_help, ExitConversation); Response (bye_allied_homeworld, ExitConversation); } @@ -525,7 +525,7 @@ NPCPhrase (ABOUT_US_2); LastStack = 2; - ActivateStarShip (SUPOX_SHIP, SPHERE_TRACKING); + StartSphereTracking (SUPOX_SHIP); SET_GAME_STATE (UTWIG_WAR_NEWS, 2); } else if (PLAYER_SAID (R, what_about_you_3)) @@ -807,7 +807,7 @@ Response (hey_wait_got_ultron, ExitConversation); } } - else if (ActivateStarShip (UTWIG_SHIP, CHECK_ALLIANCE) == GOOD_GUY) + else if (CheckAlliance (UTWIG_SHIP) == GOOD_GUY) { if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) & (1 << 7)) { Modified: trunk/sc2/src/uqm/comm/yehat/yehatc.c =================================================================== --- trunk/sc2/src/uqm/comm/yehat/yehatc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/yehat/yehatc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -309,7 +309,7 @@ else if (PLAYER_SAID (R, shofixti_alive_2)) NPCPhrase (SEND_HIM_OVER_2); - if (ActivateStarShip (SHOFIXTI_SHIP, ESCORTING_FLAGSHIP)) + if (HaveEscortShip (SHOFIXTI_SHIP)) Response (ok_send, ExitConversation); else Response (not_here, ExitConversation); Modified: trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c =================================================================== --- trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm/zoqfot/zoqfotc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -224,7 +224,7 @@ NPCPhrase_cb (WE_ALLY4, &SelectAlienZOQ); NPCPhrase_cb (WE_ALLY5, &SelectAlienPIK); ZFPTalkSegue ((COUNT)~0); - ActivateStarShip (ZOQFOTPIK_SHIP, SET_ALLIED); + SetRaceAllied (ZOQFOTPIK_SHIP, TRUE); AddEvent (RELATIVE_EVENT, 3, 0, 0, ZOQFOT_DISTRESS_EVENT); SET_GAME_STATE (ZOQFOT_HOME_VISITS, 0); } @@ -735,7 +735,7 @@ NPCPhrase_cb (GOOD9, &SelectAlienPIK); ZFPTalkSegue ((COUNT)~0); - ActivateStarShip (ZOQFOTPIK_SHIP, SET_ALLIED); + SetRaceAllied (ZOQFOTPIK_SHIP, TRUE); AddEvent (RELATIVE_EVENT, 3, 0, 0, ZOQFOT_DISTRESS_EVENT); } else if (PLAYER_SAID (R, enough_info)) @@ -748,7 +748,7 @@ Response (whats_up_homeworld, ZoqFotHome); if (PHRASE_ENABLED (any_war_news)) Response (any_war_news, ZoqFotHome); - if (ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) != GOOD_GUY) + if (CheckAlliance (ZOQFOTPIK_SHIP) != GOOD_GUY) Response (i_want_alliance, ZoqFotHome); else if (PHRASE_ENABLED (want_specific_info)) { @@ -870,12 +870,12 @@ ZFPTalkSegue ((COUNT)~0); SET_GAME_STATE (ZOQFOT_DISTRESS, 0); - ActivateStarShip (ZOQFOTPIK_SHIP, MAX_ZFP_SHIPS); + AddEscortShips (ZOQFOTPIK_SHIP, MAX_ZFP_SHIPS); } else { NumVisits = GET_GAME_STATE (ZOQFOT_HOME_VISITS); - if (ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) != GOOD_GUY) + if (CheckAlliance (ZOQFOTPIK_SHIP) != GOOD_GUY) { switch (NumVisits++) { @@ -960,7 +960,7 @@ zoqfot_desc.AlienTextWidth = (SIS_TEXT_WIDTH >> 1) - TEXT_X_OFFS; - if (ActivateStarShip (ZOQFOTPIK_SHIP, CHECK_ALLIANCE) == GOOD_GUY + if (CheckAlliance (ZOQFOTPIK_SHIP) == GOOD_GUY || LOBYTE (GLOBAL (CurrentActivity)) == WON_LAST_BATTLE) { SET_GAME_STATE (BATTLE_SEGUE, 0); Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/comm.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -1394,7 +1394,7 @@ status = HUMAN_SHIP; } } - ActivateStarShip (status, SPHERE_TRACKING); + StartSphereTracking (status); if (which_comm == ORZ_CONVERSATION || (which_comm == TALKING_PET_CONVERSATION @@ -1402,7 +1402,7 @@ || LOBYTE (GLOBAL (CurrentActivity)) == IN_LAST_BATTLE)) || (which_comm != CHMMR_CONVERSATION && which_comm != SYREEN_CONVERSATION - ))//&& ActivateStarShip (status, CHECK_ALLIANCE) == BAD_GUY)) + ))//&& CheckAlliance (status) == BAD_GUY)) BuildBattle (NPC_PLAYER_NUM); } Modified: trunk/sc2/src/uqm/gameev.c =================================================================== --- trunk/sc2/src/uqm/gameev.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/gameev.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -120,7 +120,7 @@ } break; case SHOFIXTI_RETURN_EVENT: - ActivateStarShip (SHOFIXTI_SHIP, SET_ALLIED); + SetRaceAllied (SHOFIXTI_SHIP, TRUE); GLOBAL (CrewCost) -= 2; /* crew is not an issue anymore */ SET_GAME_STATE (CREW_PURCHASED0, 0); @@ -145,7 +145,7 @@ if (SpathiPtr->actual_strength) { - ActivateStarShip (SPATHI_SHIP, SET_NOT_ALLIED); + SetRaceAllied (SPATHI_SHIP, FALSE); SET_GAME_STATE (SPATHI_SHIELDED_SELVES, 1); SpathiPtr->actual_strength = 0; } @@ -181,7 +181,7 @@ RebelPtr->loc.y = 0; UnlockFleetInfo (&GLOBAL (avail_race_q), hRoyalist); UnlockFleetInfo (&GLOBAL (avail_race_q), hRebel); - ActivateStarShip (YEHAT_REBEL_SHIP, SPHERE_TRACKING); + StartSphereTracking (YEHAT_REBEL_SHIP); break; } case SLYLANDRO_RAMP_UP: @@ -439,7 +439,7 @@ { SET_GAME_STATE (YEHAT_ABSORBED_PKUNK, 1); PkunkPtr->allied_state = DEAD_GUY; - ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING); + StartSphereTracking (YEHAT_SHIP); } else { @@ -577,7 +577,7 @@ SET_GAME_STATE (THRADD_VISITS, 0); if (ThraddPtr->allied_state == GOOD_GUY) - ActivateStarShip (THRADDASH_SHIP, SET_NOT_ALLIED); + SetRaceAllied (THRADDASH_SHIP, FALSE); } ThraddState = GET_GAME_STATE (THRADD_MISSION); Modified: trunk/sc2/src/uqm/globdata.c =================================================================== --- trunk/sc2/src/uqm/globdata.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/globdata.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -337,7 +337,7 @@ sizeof (GLOBAL_SIS (CommanderName)), GAME_STRING (NAMING_STRING_BASE + 3)); - ActivateStarShip (HUMAN_SHIP, SET_ALLIED); + SetRaceAllied (HUMAN_SHIP, TRUE); CloneShipFragment (HUMAN_SHIP, &GLOBAL (built_ship_q), 0); GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (SOL_X); Modified: trunk/sc2/src/uqm/planets/devices.c =================================================================== --- trunk/sc2/src/uqm/planets/devices.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/devices.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -258,7 +258,7 @@ HIPGROUP hGroup; FoundIlwrath = (CurStarDescPtr->Index == ILWRATH_DEFINED) - && ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING); + && StartSphereTracking (ILWRATH_SHIP); // In the Ilwrath home system and they are alive? if (!FoundIlwrath && Modified: trunk/sc2/src/uqm/planets/generate/genchmmr.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genchmmr.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genchmmr.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -107,7 +107,7 @@ } else if (GET_GAME_STATE (SUN_DEVICE_ON_SHIP) && !GET_GAME_STATE (ILWRATH_DECEIVED) - && ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING)) + && StartSphereTracking (ILWRATH_SHIP)) { PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); Modified: trunk/sc2/src/uqm/planets/generate/gendru.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gendru.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/gendru.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -88,7 +88,7 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - if (ActivateStarShip (DRUUGE_SHIP, SPHERE_TRACKING)) + if (StartSphereTracking (DRUUGE_SHIP)) { NotifyOthers (DRUUGE_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); Modified: trunk/sc2/src/uqm/planets/generate/genilw.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genilw.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genilw.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -78,7 +78,7 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - if (ActivateStarShip (ILWRATH_SHIP, SPHERE_TRACKING)) + if (StartSphereTracking (ILWRATH_SHIP)) { NotifyOthers (ILWRATH_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); Modified: trunk/sc2/src/uqm/planets/generate/genmyc.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genmyc.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genmyc.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -89,7 +89,7 @@ { if ((CurStarDescPtr->Index == MYCON_DEFINED || CurStarDescPtr->Index == SUN_DEVICE_DEFINED) - && ActivateStarShip (MYCON_SHIP, SPHERE_TRACKING)) + && StartSphereTracking (MYCON_SHIP)) { if (CurStarDescPtr->Index == MYCON_DEFINED || !GET_GAME_STATE (SUN_DEVICE_UNGUARDED)) Modified: trunk/sc2/src/uqm/planets/generate/genorz.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genorz.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genorz.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -93,7 +93,7 @@ if ((CurStarDescPtr->Index == ORZ_DEFINED || !GET_GAME_STATE (TAALO_UNPROTECTED)) - && ActivateStarShip (ORZ_SHIP, SPHERE_TRACKING)) + && StartSphereTracking (ORZ_SHIP)) { NotifyOthers (ORZ_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); Modified: trunk/sc2/src/uqm/planets/generate/genpet.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genpet.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genpet.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -83,14 +83,14 @@ if (matchWorld (solarSys, world, 0, MATCH_PLANET) && (GET_GAME_STATE (UMGAH_ZOMBIE_BLOBBIES) || !GET_GAME_STATE (TALKING_PET) - || ActivateStarShip (UMGAH_SHIP, SPHERE_TRACKING))) + || StartSphereTracking (UMGAH_SHIP))) { NotifyOthers (UMGAH_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); - if (ActivateStarShip (UMGAH_SHIP, SPHERE_TRACKING)) + if (StartSphereTracking (UMGAH_SHIP)) { GLOBAL (CurrentActivity) |= START_INTERPLANETARY; SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 7); @@ -129,7 +129,7 @@ // Defeated the zombie fleet. InitCommunication (TALKING_PET_CONVERSATION); } - else if (!(ActivateStarShip (UMGAH_SHIP, SPHERE_TRACKING))) + else if (!(StartSphereTracking (UMGAH_SHIP))) { // The Kohr-Ah have destroyed the Umgah, but the // talking pet survived. Modified: trunk/sc2/src/uqm/planets/generate/genpku.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genpku.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genpku.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -79,7 +79,7 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - if (ActivateStarShip (PKUNK_SHIP, SPHERE_TRACKING)) + if (StartSphereTracking (PKUNK_SHIP)) { NotifyOthers (PKUNK_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); Modified: trunk/sc2/src/uqm/planets/generate/gensam.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gensam.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/gensam.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -215,9 +215,8 @@ EncounterRace = -1; GLOBAL (CurrentActivity) = IN_LAST_BATTLE | START_ENCOUNTER; if (GET_GAME_STATE (YEHAT_CIVIL_WAR) - && ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING) - && ActivateStarShip (YEHAT_REBEL_SHIP, - FEASIBILITY_STUDY)) + && StartSphereTracking (YEHAT_SHIP) + && EscortFeasibilityStudy (YEHAT_REBEL_SHIP)) InitCommunication (YEHAT_REBEL_CONVERSATION); } } Modified: trunk/sc2/src/uqm/planets/generate/genspa.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genspa.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genspa.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -121,7 +121,7 @@ { /* Spathiwa's moon */ if (!GET_GAME_STATE (SPATHI_SHIELDED_SELVES) - && ActivateStarShip (SPATHI_SHIP, SPHERE_TRACKING)) + && StartSphereTracking (SPATHI_SHIP)) { NotifyOthers (SPATHI_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); Modified: trunk/sc2/src/uqm/planets/generate/gensup.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gensup.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/gensup.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -79,7 +79,7 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - if (ActivateStarShip (SUPOX_SHIP, SPHERE_TRACKING)) + if (StartSphereTracking (SUPOX_SHIP)) { NotifyOthers (SUPOX_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); Modified: trunk/sc2/src/uqm/planets/generate/genthrad.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genthrad.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genthrad.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -96,7 +96,7 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - if (ActivateStarShip (THRADDASH_SHIP, SPHERE_TRACKING) + if (StartSphereTracking (THRADDASH_SHIP) && (CurStarDescPtr->Index == THRADD_DEFINED || (!GET_GAME_STATE (HELIX_UNPROTECTED) && (BYTE)(GET_GAME_STATE (THRADD_MISSION) - 1) >= 3))) Modified: trunk/sc2/src/uqm/planets/generate/genutw.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genutw.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genutw.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -109,7 +109,7 @@ { if ((CurStarDescPtr->Index == UTWIG_DEFINED || !GET_GAME_STATE (UTWIG_HAVE_ULTRON)) - && ActivateStarShip (UTWIG_SHIP, SPHERE_TRACKING)) + && StartSphereTracking (UTWIG_SHIP)) { NotifyOthers (UTWIG_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); @@ -141,7 +141,7 @@ if (CurStarDescPtr->Index == BOMB_DEFINED && !GET_GAME_STATE (BOMB_UNPROTECTED) - && ActivateStarShip (DRUUGE_SHIP, SPHERE_TRACKING)) + && StartSphereTracking (DRUUGE_SHIP)) { COUNT i; Modified: trunk/sc2/src/uqm/planets/generate/genvux.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genvux.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genvux.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -125,7 +125,7 @@ && (CurStarDescPtr->Index == VUX_DEFINED || (CurStarDescPtr->Index == MAIDENS_DEFINED && !GET_GAME_STATE (ZEX_IS_DEAD)))) - && ActivateStarShip (VUX_SHIP, SPHERE_TRACKING)) + && StartSphereTracking (VUX_SHIP)) { NotifyOthers (VUX_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); Modified: trunk/sc2/src/uqm/planets/generate/genyeh.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genyeh.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genyeh.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -77,7 +77,7 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - if (ActivateStarShip (YEHAT_SHIP, SPHERE_TRACKING)) + if (StartSphereTracking (YEHAT_SHIP)) { NotifyOthers (YEHAT_SHIP, IPNL_ALL_CLEAR); PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); Modified: trunk/sc2/src/uqm/planets/generate/genzoq.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genzoq.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/planets/generate/genzoq.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -87,7 +87,7 @@ { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - if (ActivateStarShip (ZOQFOTPIK_SHIP, SPHERE_TRACKING)) + if (StartSphereTracking (ZOQFOTPIK_SHIP)) { PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); ReinitQueue (&GLOBAL (ip_group_q)); Modified: trunk/sc2/src/uqm/races.h =================================================================== --- trunk/sc2/src/uqm/races.h 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/races.h 2011-12-16 21:01:55 UTC (rev 3702) @@ -384,9 +384,9 @@ // Values for FLEET_INFO.allied_state enum { - DEAD_GUY = 0, - GOOD_GUY, - BAD_GUY, + DEAD_GUY = 0, // Race is extinct + GOOD_GUY, // Race is allied with the player + BAD_GUY, // Race is not allied with the player }; static inline FLEET_INFO * Modified: trunk/sc2/src/uqm/shipyard.c =================================================================== --- trunk/sc2/src/uqm/shipyard.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/shipyard.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -525,7 +525,7 @@ LockMutex (GraphicsLock); } } - if (ActivateStarShip (SHOFIXTI_SHIP, CHECK_ALLIANCE) != GOOD_GUY) + if (CheckAlliance (SHOFIXTI_SHIP) != GOOD_GUY) { SET_GAME_STATE (CREW_PURCHASED0, LOBYTE (crew_bought)); SET_GAME_STATE (CREW_PURCHASED1, HIBYTE (crew_bought)); Modified: trunk/sc2/src/uqm/uqmdebug.c =================================================================== --- trunk/sc2/src/uqm/uqmdebug.c 2011-12-16 17:30:27 UTC (rev 3701) +++ trunk/sc2/src/uqm/uqmdebug.c 2011-12-16 21:01:55 UTC (rev 3702) @@ -85,18 +85,18 @@ // Give the player the ships you can't ally with under normal // conditions. clearEscorts (); - ActivateStarShip (ARILOU_SHIP, 1); - ActivateStarShip (PKUNK_SHIP, 1); - ActivateStarShip (VUX_SHIP, 1); - ActivateStarShip (YEHAT_SHIP, 1); - ActivateStarShip (MELNORME_SHIP, 1); - ActivateStarShip (DRUUGE_SHIP, 1); - ActivateStarShip (ILWRATH_SHIP, 1); - ActivateStarShip (MYCON_SHIP, 1); - ActivateStarShip (SLYLANDRO_SHIP, 1); - ActivateStarShip (UMGAH_SHIP, 1); - ActivateStarShip (URQUAN_SHIP, 1); - ActivateStarShip (BLACK_URQUAN_SHIP, 1); + AddEscortShips (ARILOU_SHIP, 1); + AddEscortShips (PKUNK_SHIP, 1); + AddEscortShips (VUX_SHIP, 1); + AddEscortShips (YEHAT_SHIP, 1); + AddEscortShips (MELNORME_SHIP, 1); + AddEscortShips (DRUUGE_SHIP, 1); + AddEscortShips (ILWRATH_SHIP, 1); + AddEscortShips (MYCON_SHIP, 1); + AddEscortShips (SLYLANDRO_SHIP, 1); + AddEscortShips (UMGAH_SHIP, 1); + AddEscortShips (URQUAN_SHIP, 1); + AddEscortShips (BLACK_URQUAN_SHIP, 1); resetCrewBattle (); resetEnergyBattle (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-12-16 17:30:38
|
Revision: 3701 http://sc2.svn.sourceforge.net/sc2/?rev=3701&view=rev Author: Meep-Eep Date: 2011-12-16 17:30:27 +0000 (Fri, 16 Dec 2011) Log Message: ----------- Removed obsolete RESPONSE_TO_REF. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/comm/mycon/myconc.c trunk/sc2/src/uqm/commglue.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-10-01 15:55:13 UTC (rev 3700) +++ trunk/sc2/ChangeLog 2011-12-16 17:30:27 UTC (rev 3701) @@ -1,4 +1,5 @@ Changes towards version 0.8: +- Removed obsolete RESPONSE_TO_REF - SvdB - Don't require the 'shadow' dir in addon packs, from Alex - Make use of GAME_STATE_FILE consistently, from Scott A. Colcord - Fixed unconst(), from Scott A. Colcord Modified: trunk/sc2/src/uqm/comm/mycon/myconc.c =================================================================== --- trunk/sc2/src/uqm/comm/mycon/myconc.c 2011-10-01 15:55:13 UTC (rev 3700) +++ trunk/sc2/src/uqm/comm/mycon/myconc.c 2011-12-16 17:30:27 UTC (rev 3701) @@ -371,7 +371,7 @@ DoRamble (R); NPCPhrase (RAMBLE_TAIL); - DISABLE_PHRASE (RESPONSE_TO_REF (R)); + DISABLE_PHRASE (R); } if ((BYTE)TFB_Random () < 256 * 30 / 100) Modified: trunk/sc2/src/uqm/commglue.h =================================================================== --- trunk/sc2/src/uqm/commglue.h 2011-10-01 15:55:13 UTC (rev 3700) +++ trunk/sc2/src/uqm/commglue.h 2011-12-16 17:30:27 UTC (rev 3701) @@ -69,7 +69,6 @@ (*(UNICODE *)GetStringAddress ( \ SetAbsStringTableIndex (CommData.ConversationPhrases, (p)-1) \ ) = '\0') -#define RESPONSE_TO_REF(R) (R) #define Response(i,a) \ DoResponsePhrase(i,(RESPONSE_FUNC)a,0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-10-01 15:55:19
|
Revision: 3700 http://sc2.svn.sourceforge.net/sc2/?rev=3700&view=rev Author: Meep-Eep Date: 2011-10-01 15:55:13 +0000 (Sat, 01 Oct 2011) Log Message: ----------- Don't require the 'shadow' dir in addon packs, from Alex. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/uio/io.c trunk/sc2/src/libs/uio/io.h trunk/sc2/src/options.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-10-01 15:40:10 UTC (rev 3699) +++ trunk/sc2/ChangeLog 2011-10-01 15:55:13 UTC (rev 3700) @@ -1,4 +1,5 @@ Changes towards version 0.8: +- Don't require the 'shadow' dir in addon packs, from Alex - Make use of GAME_STATE_FILE consistently, from Scott A. Colcord - Fixed unconst(), from Scott A. Colcord - Fixes to a few small bugs in UIO which shouldn't have had an impact on Modified: trunk/sc2/src/libs/uio/io.c =================================================================== --- trunk/sc2/src/libs/uio/io.c 2011-10-01 15:40:10 UTC (rev 3699) +++ trunk/sc2/src/libs/uio/io.c 2011-10-01 15:55:13 UTC (rev 3700) @@ -287,6 +287,103 @@ } } +// Mount a repository directory into same repository at a different location +// From fossil. +uio_MountHandle * +uio_transplantDir(const char *mountPoint, uio_DirHandle *sourceDir, int flags, + uio_MountHandle *relative) { + uio_MountInfo *relativeInfo; + int numPDirHandles; + uio_PDirHandle **pDirHandles; + uio_MountTreeItem **treeItems; + int i; + uio_MountHandle *handle = NULL; + + if ((flags & uio_MOUNT_RDONLY) != uio_MOUNT_RDONLY) { + // Only read-only transplants supported atm + errno = ENOSYS; + return NULL; + } + + switch (flags & uio_MOUNT_LOCATION_MASK) { + case uio_MOUNT_TOP: + case uio_MOUNT_BOTTOM: + if (relative != NULL) { + errno = EINVAL; + return NULL; + } + relativeInfo = NULL; + break; + case uio_MOUNT_BELOW: + case uio_MOUNT_ABOVE: + if (relative == NULL) { + errno = EINVAL; + return NULL; + } + relativeInfo = relative->mountInfo; + break; + default: + abort(); + } + + if (mountPoint[0] == '/') + mountPoint++; + if (!validPathName(mountPoint, strlen(mountPoint))) { + errno = EINVAL; + return NULL; + } + + if (uio_getPathPhysicalDirs(sourceDir, "", 0, + &pDirHandles, &numPDirHandles, &treeItems) == -1) { + // errno is set + return NULL; + } + if (numPDirHandles == 0) { + errno = ENOENT; + return NULL; + } + + // TODO: We only transplant the first read-only physical dir that we find + // Maybe transplant all of them? We would then have several + // uio_MountHandles to return. + for (i = 0; i < numPDirHandles; ++i) { + uio_PDirHandle *pDirHandle = pDirHandles[i]; + uio_MountInfo *oldMountInfo = treeItems[i]->mountInfo; + uio_Repository *rep = oldMountInfo->mountHandle->repository; + uio_MountInfo *mountInfo; + uio_MountTree *mountTree; + + // Only interested in read-only dirs in this incarnation + if (!uio_mountInfoIsReadOnly(oldMountInfo)) + continue; + + mountInfo = uio_MountInfo_new(oldMountInfo->fsID, NULL, pDirHandle, + uio_strdup(""), oldMountInfo->autoMount, NULL, flags); + // New mount references the same handles + uio_PDirHandle_ref(pDirHandle); + uio_PRoot_refMount(pDirHandle->pRoot); + + uio_repositoryAddMount(rep, mountInfo, + flags & uio_MOUNT_LOCATION_MASK, relativeInfo); + mountTree = uio_mountTreeAddMountInfo(rep, rep->mountTree, + mountInfo, mountPoint, flags & uio_MOUNT_LOCATION_MASK, + relativeInfo); + // mountTree is the node in rep->mountTree where mountInfo leads to + mountInfo->mountTree = mountTree; + mountInfo->mountHandle = uio_MountHandle_new(rep, mountInfo); + handle = mountInfo->mountHandle; + break; + } + + uio_PDirHandles_delete(pDirHandles, numPDirHandles); + uio_free(treeItems); + + if (handle == NULL) + errno = ENOENT; + + return handle; +} + int uio_unmountDir(uio_MountHandle *mountHandle) { uio_PRoot *pRoot; Modified: trunk/sc2/src/libs/uio/io.h =================================================================== --- trunk/sc2/src/libs/uio/io.h 2011-10-01 15:40:10 UTC (rev 3699) +++ trunk/sc2/src/libs/uio/io.h 2011-10-01 15:55:13 UTC (rev 3700) @@ -82,6 +82,12 @@ const char *inPath, uio_AutoMount **autoMount, int flags, uio_MountHandle *relative); +// Mount a repository directory into same repository at a different +// location. +// From fossil. +uio_MountHandle *uio_transplantDir(const char *mountPoint, + uio_DirHandle *sourceDir, int flags, uio_MountHandle *relative); + // Unmount a previously mounted dir. int uio_unmountDir(uio_MountHandle *mountHandle); Modified: trunk/sc2/src/options.c =================================================================== --- trunk/sc2/src/options.c 2011-10-01 15:40:10 UTC (rev 3699) +++ trunk/sc2/src/options.c 2011-10-01 15:55:13 UTC (rev 3700) @@ -571,6 +571,14 @@ { log_add (log_Debug, "Mounting shadow content of '%s' addon", addon); mountDirZips (shadowDir, "/", uio_MOUNT_ABOVE, contentMountHandle); + // Mount non-zipped shadow content + if (uio_transplantDir ("/", shadowDir, uio_MOUNT_RDONLY | + uio_MOUNT_ABOVE, contentMountHandle) == NULL) + { + log_add (log_Warning, "Warning: Could not mount shadow content" + " of '%s': %s.", addon, strerror (errno)); + } + uio_closeDir (shadowDir); } uio_closeDir (addonDir); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-10-01 15:40:16
|
Revision: 3699 http://sc2.svn.sourceforge.net/sc2/?rev=3699&view=rev Author: Meep-Eep Date: 2011-10-01 15:40:10 +0000 (Sat, 01 Oct 2011) Log Message: ----------- Some comments for easier counting. Modified Paths: -------------- trunk/sc2/content/base/gamestrings.txt Modified: trunk/sc2/content/base/gamestrings.txt =================================================================== --- trunk/sc2/content/base/gamestrings.txt 2011-10-01 15:30:21 UTC (rev 3698) +++ trunk/sc2/content/base/gamestrings.txt 2011-10-01 15:40:10 UTC (rev 3699) @@ -1,4 +1,4 @@ -#(Vega) +#(Vega) -- STAR_STRING_BASE Vega @@ -530,7 +530,7 @@ UNKNOWN -#(devices) +#(devices) -- DEVICE_STRING_BASE devices @@ -646,7 +646,7 @@ Moon Base -#(cargo) +#(cargo) -- CARGO_STRING_BASE cargo @@ -686,7 +686,7 @@ Exotic -#(Hydrogen) +#(Hydrogen) -- ELEMENTS_STRING_BASE Hydrogen @@ -1218,7 +1218,7 @@ Nitric Acid -#(MINERAL SCAN) +#(MINERAL SCAN) -- SCAN_STRING_BASE MINERAL SCAN @@ -1442,7 +1442,7 @@ Gas Giant -#(Alpha) +#(Alpha) -- STAR_NUMBER_BASE Alpha @@ -1498,7 +1498,7 @@ Xi -#(Mercury) +#(Mercury) -- PLANET_NUMBER_BASE Mercury @@ -1625,10 +1625,12 @@ #(Planet XVI) Planet XVI + #(Sa-Matra) Sa-Matra -#(JAN) + +#(JAN) -- MONTHS_STRING_BASE JAN @@ -1676,7 +1678,7 @@ DEC -#((In response to your statement)) +#((In response to your statement)) -- FEEDBACK_STRING_BASE (In response to your statement) @@ -1684,7 +1686,7 @@ MORE -#(Starbase) +#(Starbase) -- STARBASE_STRING_BASE Starbase @@ -1704,7 +1706,7 @@ Depart StarBase -#(ENCOUNTER IN) +#(ENCOUNTER IN) -- ENCOUNTER_STRING_BASE ENCOUNTER IN @@ -1736,7 +1738,7 @@ Scavenged -#(HyperSpace) +#(HyperSpace) -- NAVIGATION_STRING_BASE HyperSpace @@ -1760,7 +1762,7 @@ Fuel Use: -#(Enter name) +#(Enter name) -- NAMING_STRING_BASE Enter name @@ -1776,7 +1778,7 @@ Zelnick -#(Empty) +#(Empty) -- MELEE_STRING_BASE Empty @@ -1812,7 +1814,7 @@ The Peeled Eyes -#(Saving . . .) +#(Saving . . .) -- SAVEGAME_STRING_BASE Saving . . . @@ -1832,7 +1834,7 @@ Saved Game - Date: -#(Sound) +#(Sound) -- OPTION_STRING_BASE Sound @@ -1852,7 +1854,7 @@ ON -#(Really Quit) +#(Really Quit) -- QUITMENU_STRING_BASE Really Quit? @@ -1864,7 +1866,7 @@ No -#(Cr) +#(Cr) -- STATUS_STRING_BASE Cr @@ -1888,7 +1890,7 @@ CAPTAIN -#(nose:) +#(nose:) -- FLAGSHIP_STRING_BASE nose: @@ -1940,7 +1942,7 @@ none -#(Orbit: ) +#(Orbit: ) -- ORBITSCAN_STRING_BASE Orbit: @@ -2016,7 +2018,7 @@ Tilt: -#(scan) +#(scan) -- MAINMENU_STRING_BASE scan @@ -2237,7 +2239,7 @@ Please press ENTER or SPACE to return. -#(Unconnected. Press LEFT to connect.) +#(Unconnected. Press LEFT to connect.) -- NETMELEE_STRING_BASE Unconnected. Press LEFT to connect. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-10-01 15:30:27
|
Revision: 3698 http://sc2.svn.sourceforge.net/sc2/?rev=3698&view=rev Author: Meep-Eep Date: 2011-10-01 15:30:21 +0000 (Sat, 01 Oct 2011) Log Message: ----------- Update. Modified Paths: -------------- trunk/sc2/doc/devel/netplay/todo Modified: trunk/sc2/doc/devel/netplay/todo =================================================================== --- trunk/sc2/doc/devel/netplay/todo 2011-10-01 14:54:18 UTC (rev 3697) +++ trunk/sc2/doc/devel/netplay/todo 2011-10-01 15:30:21 UTC (rev 3698) @@ -14,6 +14,9 @@ - Closing and destroying of NetConnections is a terrible mess. - Checks allConnected() shouldn't be needed if CHECK_ABORT is set on disconnect. +- Shorten or lengthen the time between frames depending on how full the input + buffer is, to prevent one side constantly stalling when the connection in + one direction is slower than in the other direction. Low-priority: @@ -75,6 +78,7 @@ - Per state data (in NetConnection.stateData) is unnecessarilly complicated. Putting all fields directly in NetConnection simplifies things a lot. It's not as generic, but this code won't be used elsewhere anyhow. +- Send captain names to the other side Bugs: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-10-01 14:54:24
|
Revision: 3697 http://sc2.svn.sourceforge.net/sc2/?rev=3697&view=rev Author: Meep-Eep Date: 2011-10-01 14:54:18 +0000 (Sat, 01 Oct 2011) Log Message: ----------- Make use of GAME_STATE_FILE consistently. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/uqm/grpinfo.c trunk/sc2/src/uqm/state.c trunk/sc2/src/uqm/state.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-10-01 14:15:35 UTC (rev 3696) +++ trunk/sc2/ChangeLog 2011-10-01 14:54:18 UTC (rev 3697) @@ -1,4 +1,5 @@ Changes towards version 0.8: +- Make use of GAME_STATE_FILE consistently, from Scott A. Colcord - Fixed unconst(), from Scott A. Colcord - Fixes to a few small bugs in UIO which shouldn't have had an impact on UQM, but would in the future, from Alex Modified: trunk/sc2/src/uqm/grpinfo.c =================================================================== --- trunk/sc2/src/uqm/grpinfo.c 2011-10-01 14:15:35 UTC (rev 3696) +++ trunk/sc2/src/uqm/grpinfo.c 2011-10-01 14:54:18 UTC (rev 3697) @@ -71,7 +71,7 @@ } GROUP_HEADER; static void -ReadGroupHeader (void *fp, GROUP_HEADER *pGH) +ReadGroupHeader (GAME_STATE_FILE *fp, GROUP_HEADER *pGH) { sread_8 (fp, &pGH->NumGroups); sread_8 (fp, &pGH->day_index); @@ -83,7 +83,7 @@ } static void -WriteGroupHeader (void *fp, const GROUP_HEADER *pGH) +WriteGroupHeader (GAME_STATE_FILE *fp, const GROUP_HEADER *pGH) { swrite_8 (fp, pGH->NumGroups); swrite_8 (fp, pGH->day_index); @@ -95,7 +95,7 @@ } static void -ReadShipFragment (void *fp, SHIP_FRAGMENT *FragPtr) +ReadShipFragment (GAME_STATE_FILE *fp, SHIP_FRAGMENT *FragPtr) { BYTE tmpb; @@ -117,7 +117,7 @@ } static void -WriteShipFragment (void *fp, const SHIP_FRAGMENT *FragPtr) +WriteShipFragment (GAME_STATE_FILE *fp, const SHIP_FRAGMENT *FragPtr) { swrite_16 (fp, 0); /* unused: was which_side */ swrite_8 (fp, FragPtr->captains_name_index); @@ -135,7 +135,7 @@ } static void -ReadIpGroup (void *fp, IP_GROUP *GroupPtr) +ReadIpGroup (GAME_STATE_FILE *fp, IP_GROUP *GroupPtr) { BYTE tmpb; @@ -158,7 +158,7 @@ } static void -WriteIpGroup (void *fp, const IP_GROUP *GroupPtr) +WriteIpGroup (GAME_STATE_FILE *fp, const IP_GROUP *GroupPtr) { swrite_16 (fp, 0); /* unused; was which_side */ swrite_8 (fp, 0); /* unused; was captains_name_index */ @@ -181,7 +181,7 @@ void InitGroupInfo (BOOLEAN FirstTime) { - void *fp; + GAME_STATE_FILE *fp; assert (NUM_SAVED_BATTLE_GROUPS >= MAX_BATTLE_GROUPS); @@ -413,7 +413,7 @@ } static void -FlushGroupInfo (GROUP_HEADER* pGH, DWORD offset, BYTE which_group, void *fp) +FlushGroupInfo (GROUP_HEADER* pGH, DWORD offset, BYTE which_group, GAME_STATE_FILE *fp) { if (which_group == GROUP_LIST) { @@ -549,7 +549,7 @@ BOOLEAN GetGroupInfo (DWORD offset, BYTE which_group) { - void *fp; + GAME_STATE_FILE *fp; GROUP_HEADER GH; if (offset != GROUPS_RANDOM && which_group != GROUP_LIST) @@ -828,7 +828,7 @@ DWORD PutGroupInfo (DWORD offset, BYTE which_group) { - void *fp; + GAME_STATE_FILE *fp; GROUP_HEADER GH; if (offset != GROUPS_RANDOM && which_group != GROUP_LIST) Modified: trunk/sc2/src/uqm/state.c =================================================================== --- trunk/sc2/src/uqm/state.c 2011-10-01 14:15:35 UTC (rev 3696) +++ trunk/sc2/src/uqm/state.c 2011-10-01 14:54:18 UTC (rev 3697) @@ -239,7 +239,7 @@ void GetPlanetInfo (void) { - void *fp; + GAME_STATE_FILE *fp; pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN] = 0; pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[MINERAL_SCAN] = 0; @@ -287,7 +287,7 @@ void PutPlanetInfo (void) { - void *fp; + GAME_STATE_FILE *fp; fp = OpenStateFile (STARINFO_FILE, "r+b"); if (fp) Modified: trunk/sc2/src/uqm/state.h =================================================================== --- trunk/sc2/src/uqm/state.h 2011-10-01 14:15:35 UTC (rev 3696) +++ trunk/sc2/src/uqm/state.h 2011-10-01 14:54:18 UTC (rev 3697) @@ -79,7 +79,7 @@ int SeekStateFile (GAME_STATE_FILE *fp, long offset, int whence); static inline COUNT -sread_8 (void *fp, BYTE *v) +sread_8 (GAME_STATE_FILE *fp, BYTE *v) { BYTE t; if (!v) /* read value ignored */ @@ -88,7 +88,7 @@ } static inline COUNT -sread_16 (void *fp, UWORD *v) +sread_16 (GAME_STATE_FILE *fp, UWORD *v) { UWORD t; if (!v) /* read value ignored */ @@ -97,7 +97,7 @@ } static inline COUNT -sread_16s (void *fp, SWORD *v) +sread_16s (GAME_STATE_FILE *fp, SWORD *v) { UWORD t; COUNT ret; @@ -109,7 +109,7 @@ } static inline COUNT -sread_32 (void *fp, DWORD *v) +sread_32 (GAME_STATE_FILE *fp, DWORD *v) { DWORD t; if (!v) /* read value ignored */ @@ -118,7 +118,7 @@ } static inline COUNT -sread_a32 (void *fp, DWORD *ar, COUNT count) +sread_a32 (GAME_STATE_FILE *fp, DWORD *ar, COUNT count) { assert (ar != NULL); @@ -131,25 +131,25 @@ } static inline COUNT -swrite_8 (void *fp, BYTE v) +swrite_8 (GAME_STATE_FILE *fp, BYTE v) { return WriteStateFile (&v, 1, 1, fp); } static inline COUNT -swrite_16 (void *fp, UWORD v) +swrite_16 (GAME_STATE_FILE *fp, UWORD v) { return WriteStateFile (&v, 2, 1, fp); } static inline COUNT -swrite_32 (void *fp, DWORD v) +swrite_32 (GAME_STATE_FILE *fp, DWORD v) { return WriteStateFile (&v, 4, 1, fp); } static inline COUNT -swrite_a32 (void *fp, const DWORD *ar, COUNT count) +swrite_a32 (GAME_STATE_FILE *fp, const DWORD *ar, COUNT count) { for ( ; count > 0; --count, ++ar) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Mee...@us...> - 2011-10-01 14:15:42
|
Revision: 3696 http://sc2.svn.sourceforge.net/sc2/?rev=3696&view=rev Author: Meep-Eep Date: 2011-10-01 14:15:35 +0000 (Sat, 01 Oct 2011) Log Message: ----------- Fixed unconst() types. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/misc.h trunk/sc2/src/libs/uio/uioutils.h Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-09-09 21:36:34 UTC (rev 3695) +++ trunk/sc2/ChangeLog 2011-10-01 14:15:35 UTC (rev 3696) @@ -1,4 +1,5 @@ Changes towards version 0.8: +- Fixed unconst(), from Scott A. Colcord - Fixes to a few small bugs in UIO which shouldn't have had an impact on UQM, but would in the future, from Alex - Allow F6 as a default alternate search key, from related projects. Modified: trunk/sc2/src/libs/misc.h =================================================================== --- trunk/sc2/src/libs/misc.h 2011-09-09 21:36:34 UTC (rev 3695) +++ trunk/sc2/src/libs/misc.h 2011-10-01 14:15:35 UTC (rev 3696) @@ -51,8 +51,8 @@ static inline void * unconst(const void *arg) { union { - char *c; - const char *cc; + void *c; + const void *cc; } u; u.cc = arg; return u.c; Modified: trunk/sc2/src/libs/uio/uioutils.h =================================================================== --- trunk/sc2/src/libs/uio/uioutils.h 2011-09-09 21:36:34 UTC (rev 3695) +++ trunk/sc2/src/libs/uio/uioutils.h 2011-10-01 14:15:35 UTC (rev 3696) @@ -44,8 +44,8 @@ static inline void * unconst(const void *arg) { union { - char *c; - const char *cc; + void *c; + const void *cc; } u; u.cc = arg; return u.c; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-09 21:36:42
|
Revision: 3695 http://sc2.svn.sourceforge.net/sc2/?rev=3695&view=rev Author: avolkov Date: 2011-09-09 21:36:34 +0000 (Fri, 09 Sep 2011) Log Message: ----------- Refactor scan nodes generation funcs: get rid of PLANET_INFO.CurXXX fields and pass a struct to generation funcs to fill instead; makes SOLARSYS_STATE const for the funcs; gets rid of unconst casts; bug #50 Modified Paths: -------------- trunk/sc2/src/uqm/planets/generate/genand.c trunk/sc2/src/uqm/planets/generate/genburv.c trunk/sc2/src/uqm/planets/generate/gendefault.c trunk/sc2/src/uqm/planets/generate/gendefault.h trunk/sc2/src/uqm/planets/generate/gendru.c trunk/sc2/src/uqm/planets/generate/genilw.c trunk/sc2/src/uqm/planets/generate/genmyc.c trunk/sc2/src/uqm/planets/generate/genorz.c trunk/sc2/src/uqm/planets/generate/genpet.c trunk/sc2/src/uqm/planets/generate/genpku.c trunk/sc2/src/uqm/planets/generate/gensol.c trunk/sc2/src/uqm/planets/generate/genspa.c trunk/sc2/src/uqm/planets/generate/gensup.c trunk/sc2/src/uqm/planets/generate/genthrad.c trunk/sc2/src/uqm/planets/generate/genutw.c trunk/sc2/src/uqm/planets/generate/genvault.c trunk/sc2/src/uqm/planets/generate/genvux.c trunk/sc2/src/uqm/planets/generate/genwreck.c trunk/sc2/src/uqm/planets/generate/genyeh.c trunk/sc2/src/uqm/planets/generate/genzoq.c trunk/sc2/src/uqm/planets/generate.h trunk/sc2/src/uqm/planets/plandata.h trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/scan.h trunk/sc2/src/uqm/planets/sundata.h trunk/sc2/src/uqm/planets/surface.c trunk/sc2/src/uqm/uqmdebug.c Modified: trunk/sc2/src/uqm/planets/generate/genand.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genand.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genand.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -30,8 +30,8 @@ static bool GenerateAndrosynth_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateAndrosynth_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateAndrosynth_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateAndrosynth_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateAndrosynth_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -152,12 +152,12 @@ } static COUNT -GenerateAndrosynth_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateAndrosynth_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 1, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genburv.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genburv.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genburv.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -30,8 +30,8 @@ PLANET_DESC *planet); static bool GenerateBurvixese_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateBurvixese_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateBurvixese_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateBurvixese_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -104,11 +104,11 @@ rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; - GenerateLifeForms (&solarSys->SysInfo, GENERATE_ALL); + GenerateLifeForms (&solarSys->SysInfo, GENERATE_ALL, NULL); rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL); + GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL, NULL); solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; @@ -140,12 +140,12 @@ } static COUNT -GenerateBurvixese_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateBurvixese_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } if (matchWorld (solarSys, world, 0, 0)) @@ -157,7 +157,7 @@ return 0; } - return GenerateDefault_generateArtifact (solarSys, whichNode); + return GenerateDefault_generateArtifact (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/gendefault.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gendefault.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/gendefault.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -27,17 +27,6 @@ #include "libs/mathlib.h" -bool GenerateDefault_initNpcs (SOLARSYS_STATE *solarSys); -bool GenerateDefault_reinitNpcs (SOLARSYS_STATE *solarSys); -bool GenerateDefault_uninitNpcs (SOLARSYS_STATE *solarSys); -bool GenerateDefault_generatePlanets (SOLARSYS_STATE *solarSys); -bool GenerateDefault_generateMoons (SOLARSYS_STATE *solarSys, - PLANET_DESC *planet); -bool GenerateDefault_generateName (SOLARSYS_STATE *solarSys, - PLANET_DESC *world); -bool GenerateDefault_generateOrbital (SOLARSYS_STATE *solarSys, - PLANET_DESC *world); - static void GeneratePlanets (SOLARSYS_STATE *system); static void check_yehat_rebellion (void); @@ -113,7 +102,8 @@ } bool -GenerateDefault_generateName (SOLARSYS_STATE *solarSys, PLANET_DESC *world) +GenerateDefault_generateName (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world) { COUNT i = planetIndex (solarSys, world); utf8StringCopy (GLOBAL_SIS (PlanetName), sizeof (GLOBAL_SIS (PlanetName)), @@ -149,11 +139,11 @@ rand_val = RandomContext_GetSeed (SysGenRNG); sysInfo->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; - GenerateLifeForms (sysInfo, GENERATE_ALL); + GenerateLifeForms (sysInfo, GENERATE_ALL, NULL); rand_val = RandomContext_GetSeed (SysGenRNG); sysInfo->PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - GenerateMineralDeposits (sysInfo, GENERATE_ALL); + GenerateMineralDeposits (sysInfo, GENERATE_ALL, NULL); sysInfo->PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; LoadPlanet (NULL); @@ -162,10 +152,10 @@ } COUNT -GenerateDefault_generateMinerals (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode) +GenerateDefault_generateMinerals (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { - return GenerateMineralDeposits (&solarSys->SysInfo, whichNode); + return GenerateMineralDeposits (&solarSys->SysInfo, whichNode, info); (void) world; } @@ -181,12 +171,13 @@ } COUNT -GenerateDefault_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateDefault_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { (void) whichNode; (void) solarSys; (void) world; + (void) info; return 0; } @@ -204,10 +195,10 @@ } COUNT -GenerateDefault_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateDefault_generateLife (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { - return GenerateLifeForms (&solarSys->SysInfo, whichNode); + return GenerateLifeForms (&solarSys->SysInfo, whichNode, info); (void) world; } @@ -223,18 +214,21 @@ } COUNT -GenerateDefault_generateArtifact (SOLARSYS_STATE *solarSys, COUNT whichNode) +GenerateDefault_generateArtifact (const SOLARSYS_STATE *solarSys, + COUNT whichNode, NODE_INFO *info) { // Generate an energy node at a random location - return GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, 1, 0, whichNode); + return GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, 1, 0, + whichNode, info); } COUNT -GenerateDefault_generateRuins (SOLARSYS_STATE *solarSys, COUNT whichNode) +GenerateDefault_generateRuins (const SOLARSYS_STATE *solarSys, + COUNT whichNode, NODE_INFO *info) { // Generate a standard spread of city ruins of a destroyed civilization return GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, NUM_RACE_RUINS, - 0, whichNode); + 0, whichNode, info); } static inline void Modified: trunk/sc2/src/uqm/planets/generate/gendefault.h =================================================================== --- trunk/sc2/src/uqm/planets/generate/gendefault.h 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/gendefault.h 2011-09-09 21:36:34 UTC (rev 3695) @@ -31,16 +31,16 @@ bool GenerateDefault_generatePlanets (SOLARSYS_STATE *solarSys); bool GenerateDefault_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet); -bool GenerateDefault_generateName (SOLARSYS_STATE *solarSys, - PLANET_DESC *world); +bool GenerateDefault_generateName (const SOLARSYS_STATE *, + const PLANET_DESC *world); bool GenerateDefault_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -COUNT GenerateDefault_generateMinerals (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); -COUNT GenerateDefault_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); -COUNT GenerateDefault_generateLife (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +COUNT GenerateDefault_generateMinerals (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); +COUNT GenerateDefault_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); +COUNT GenerateDefault_generateLife (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); bool GenerateDefault_pickupMinerals (SOLARSYS_STATE *, PLANET_DESC *world, COUNT whichNode); bool GenerateDefault_pickupEnergy (SOLARSYS_STATE *, PLANET_DESC *world, @@ -48,8 +48,10 @@ bool GenerateDefault_pickupLife (SOLARSYS_STATE *, PLANET_DESC *world, COUNT whichNode); -COUNT GenerateDefault_generateArtifact (SOLARSYS_STATE *, COUNT whichNode); -COUNT GenerateDefault_generateRuins (SOLARSYS_STATE *, COUNT whichNode); +COUNT GenerateDefault_generateArtifact (const SOLARSYS_STATE *, + COUNT whichNode, NODE_INFO *info); +COUNT GenerateDefault_generateRuins (const SOLARSYS_STATE *, + COUNT whichNode, NODE_INFO *info); bool GenerateDefault_landerReport (SOLARSYS_STATE *); bool GenerateDefault_landerReportCycle (SOLARSYS_STATE *); Modified: trunk/sc2/src/uqm/planets/generate/gendru.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gendru.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/gendru.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -33,8 +33,8 @@ static bool GenerateDruuge_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateDruuge_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateDruuge_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateDruuge_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateDruuge_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -156,12 +156,12 @@ } static COUNT -GenerateDruuge_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateDruuge_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genilw.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genilw.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genilw.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -30,8 +30,8 @@ static bool GenerateIlwrath_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateIlwrath_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateIlwrath_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateIlwrath_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateIlwrath_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -123,12 +123,12 @@ } static COUNT -GenerateIlwrath_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateIlwrath_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genmyc.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genmyc.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genmyc.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -35,10 +35,10 @@ static bool GenerateMycon_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateMycon_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateMycon_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); -static COUNT GenerateMycon_generateLife (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateMycon_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); +static COUNT GenerateMycon_generateLife (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateMycon_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -189,8 +189,8 @@ } static COUNT -GenerateMycon_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateMycon_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (CurStarDescPtr->Index == SUN_DEVICE_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) @@ -202,7 +202,7 @@ return 0; } - return GenerateDefault_generateArtifact (solarSys, whichNode); + return GenerateDefault_generateArtifact (solarSys, whichNode, info); } if ((CurStarDescPtr->Index == EGG_CASE0_DEFINED @@ -219,7 +219,7 @@ return 0; } - return GenerateDefault_generateArtifact (solarSys, whichNode); + return GenerateDefault_generateArtifact (solarSys, whichNode, info); } return 0; @@ -275,12 +275,14 @@ } static COUNT -GenerateMycon_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateMycon_generateLife (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { + // Gee, I wonder why there isn't any life in Mycon systems... (void) whichNode; (void) solarSys; (void) world; + (void) info; return 0; } Modified: trunk/sc2/src/uqm/planets/generate/genorz.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genorz.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genorz.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -34,8 +34,8 @@ static bool GenerateOrz_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateOrz_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateOrz_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateOrz_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateOrz_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -168,8 +168,8 @@ } static COUNT -GenerateOrz_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateOrz_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (CurStarDescPtr->Index == TAALO_PROTECTOR_DEFINED && matchWorld (solarSys, world, 1, 2)) @@ -181,13 +181,13 @@ return 0; } - return GenerateDefault_generateArtifact (solarSys, whichNode); + return GenerateDefault_generateArtifact (solarSys, whichNode, info); } if (CurStarDescPtr->Index == ORZ_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genpet.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genpet.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genpet.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -33,8 +33,8 @@ static bool GenerateTalkingPet_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateTalkingPet_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateTalkingPet_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateTalkingPet_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateTalkingPet_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -161,12 +161,12 @@ } static COUNT -GenerateTalkingPet_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateTalkingPet_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genpku.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genpku.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genpku.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -31,8 +31,8 @@ static bool GeneratePkunk_generatePlanets (SOLARSYS_STATE *solarSys); static bool GeneratePkunk_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GeneratePkunk_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GeneratePkunk_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GeneratePkunk_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -146,12 +146,12 @@ } static COUNT -GeneratePkunk_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GeneratePkunk_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/gensol.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gensol.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/gensol.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -35,14 +35,14 @@ static bool GenerateSol_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateSol_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet); -static bool GenerateSol_generateName (SOLARSYS_STATE *solarSys, - PLANET_DESC *world); +static bool GenerateSol_generateName (const SOLARSYS_STATE *, + const PLANET_DESC *world); static bool GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateSol_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); -static COUNT GenerateSol_generateLife (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateSol_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); +static COUNT GenerateSol_generateLife (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateSol_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -241,7 +241,8 @@ } static bool -GenerateSol_generateName (SOLARSYS_STATE *solarSys, PLANET_DESC *world) +GenerateSol_generateName (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world) { COUNT planetNr = planetIndex (solarSys, world); utf8StringCopy (GLOBAL_SIS (PlanetName), sizeof (GLOBAL_SIS (PlanetName)), @@ -274,7 +275,7 @@ rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL); + GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL, NULL); rand_val = RandomContext_GetSeed (SysGenRNG); planetNr = planetIndex (solarSys, world); @@ -514,8 +515,8 @@ } static COUNT -GenerateSol_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateSol_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 8, MATCH_PLANET)) { @@ -527,8 +528,11 @@ return 0; } - solarSys->SysInfo.PlanetInfo.CurPt.x = 20; - solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT - 8; + if (info) + { + info->loc_pt.x = 20; + info->loc_pt.y = MAP_HEIGHT - 8; + } return 1; // only matters when count is requested } @@ -543,8 +547,11 @@ return 0; } - solarSys->SysInfo.PlanetInfo.CurPt.x = MAP_WIDTH * 3 / 4; - solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT * 1 / 4; + if (info) + { + info->loc_pt.x = MAP_WIDTH * 3 / 4; + info->loc_pt.y = MAP_HEIGHT * 1 / 4; + } return 1; // only matters when count is requested } @@ -595,14 +602,14 @@ } static COUNT -GenerateSol_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateSol_generateLife (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 2, 1)) { /* Earth Moon */ return GenerateRandomNodes (&solarSys->SysInfo, BIOLOGICAL_SCAN, 10, - NUM_CREATURE_TYPES + 1, whichNode); + NUM_CREATURE_TYPES + 1, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genspa.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genspa.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genspa.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -35,10 +35,10 @@ PLANET_DESC *planet); static bool GenerateSpathi_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateSpathi_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); -static COUNT GenerateSpathi_generateLife (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateSpathi_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); +static COUNT GenerateSpathi_generateLife (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateSpathi_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); static bool GenerateSpathi_pickupLife (SOLARSYS_STATE *solarSys, @@ -148,11 +148,11 @@ rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; - GenerateLifeForms (&solarSys->SysInfo, GENERATE_ALL); + GenerateLifeForms (&solarSys->SysInfo, GENERATE_ALL, NULL); rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL); + GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL, NULL); solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; @@ -185,7 +185,7 @@ rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL); + GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL, NULL); rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; @@ -207,8 +207,8 @@ } static COUNT -GenerateSpathi_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateSpathi_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, 0)) { @@ -219,7 +219,7 @@ return 0; } - return GenerateDefault_generateArtifact (solarSys, whichNode); + return GenerateDefault_generateArtifact (solarSys, whichNode, info); } return 0; @@ -247,14 +247,14 @@ } static COUNT -GenerateSpathi_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateSpathi_generateLife (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { #define NUM_EVIL_ONES 32 return GenerateRandomNodes (&solarSys->SysInfo, BIOLOGICAL_SCAN, NUM_EVIL_ONES, - NUM_CREATURE_TYPES, whichNode); + NUM_CREATURE_TYPES, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/gensup.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gensup.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/gensup.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -31,8 +31,8 @@ static bool GenerateSupox_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateSupox_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateSupox_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateSupox_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateSupox_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -146,12 +146,12 @@ } static COUNT -GenerateSupox_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateSupox_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genthrad.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genthrad.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genthrad.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -34,8 +34,8 @@ static bool GenerateThraddash_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateThraddash_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateThraddash_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateThraddash_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateThraddash_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -161,13 +161,13 @@ } static COUNT -GenerateThraddash_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode) +GenerateThraddash_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (CurStarDescPtr->Index == THRADD_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } if (CurStarDescPtr->Index == AQUA_HELIX_DEFINED @@ -180,7 +180,7 @@ return 0; } - return GenerateDefault_generateArtifact (solarSys, whichNode); + return GenerateDefault_generateArtifact (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genutw.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genutw.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genutw.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -35,8 +35,8 @@ static bool GenerateUtwig_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateUtwig_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateUtwig_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateUtwig_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateUtwig_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -212,13 +212,13 @@ } static COUNT -GenerateUtwig_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateUtwig_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (CurStarDescPtr->Index == UTWIG_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } if (CurStarDescPtr->Index == BOMB_DEFINED @@ -231,7 +231,7 @@ return 0; } - return GenerateDefault_generateArtifact (solarSys, whichNode); + return GenerateDefault_generateArtifact (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genvault.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genvault.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genvault.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -27,8 +27,8 @@ static bool GenerateVault_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateVault_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateVault_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateVault_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -79,12 +79,12 @@ } static COUNT -GenerateVault_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateVault_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, 0)) { - return GenerateDefault_generateArtifact (solarSys, whichNode); + return GenerateDefault_generateArtifact (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genvux.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genvux.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genvux.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -36,10 +36,10 @@ static bool GenerateVux_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateVux_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateVux_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); -static COUNT GenerateVux_generateLife (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateVux_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); +static COUNT GenerateVux_generateLife (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateVux_pickupEnergy (SOLARSYS_STATE *, PLANET_DESC *world, COUNT whichNode); static bool GenerateVux_pickupLife (SOLARSYS_STATE *, PLANET_DESC *world, @@ -211,8 +211,8 @@ } static COUNT -GenerateVux_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateVux_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (CurStarDescPtr->Index == MAIDENS_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) @@ -224,8 +224,11 @@ return 0; } - solarSys->SysInfo.PlanetInfo.CurPt.x = MAP_WIDTH / 3; - solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT * 5 / 8; + if (info) + { + info->loc_pt.x = MAP_WIDTH / 3; + info->loc_pt.y = MAP_HEIGHT * 5 / 8; + } return 1; // only matters when count is requested } @@ -233,7 +236,7 @@ if (CurStarDescPtr->Index == VUX_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } return 0; @@ -270,56 +273,37 @@ } static COUNT -GenerateVux_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateVux_generateLife (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (CurStarDescPtr->Index == MAIDENS_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { - COUNT i; - - RandomContext_SeedRandom (SysGenRNG, - solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); - - for (i = 0; i <= whichNode && i < 12; ++i) + static const SBYTE life[] = { - GenerateRandomLocation (&solarSys->SysInfo); - if (i < 4) - solarSys->SysInfo.PlanetInfo.CurType = 9; - else if (i < 8) - solarSys->SysInfo.PlanetInfo.CurType = 14; - else /* if (i < 12) */ - solarSys->SysInfo.PlanetInfo.CurType = 18; - } - - return 12; // only matters when count is requested + 9, 9, 9, 9, /* Carousel Beast */ + 14, 14, 14, 14, /* Amorphous Trandicula */ + 18, 18, 18, 18, /* Penguin Cyclops */ + -1 /* term */ + }; + return GeneratePresetLife (&solarSys->SysInfo, life, whichNode, info); } if (CurStarDescPtr->Index == VUX_BEAST_DEFINED && matchWorld (solarSys, world, 0, MATCH_PLANET)) { - COUNT i; - - RandomContext_SeedRandom (SysGenRNG, - solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); - - for (i = 0; i <= whichNode && i < 11; ++i) + static const SBYTE life[] = { - GenerateRandomLocation (&solarSys->SysInfo); - if (i == 0) /* VUX Beast */ - solarSys->SysInfo.PlanetInfo.CurType = NUM_CREATURE_TYPES + 2; - else if (i <= 5) - /* {SPEED_MOTIONLESS | DANGER_NORMAL, MAKE_BYTE (5, 3)}, */ - solarSys->SysInfo.PlanetInfo.CurType = 3; - else /* if (i <= 10) */ - /* {BEHAVIOR_UNPREDICTABLE | SPEED_SLOW | DANGER_NORMAL, MAKE_BYTE (3, 8)}, */ - solarSys->SysInfo.PlanetInfo.CurType = 8; - } - - return 11; // only matters when count is requested + NUM_CREATURE_TYPES + 2, /* VUX Beast */ + // Must be the first node, see pickupLife() below + 3, 3, 3, 3, 3, /* Whackin' Bush */ + 8, 8, 8, 8, 8, /* Glowing Medusa */ + -1 /* term */ + }; + return GeneratePresetLife (&solarSys->SysInfo, life, whichNode, info); } - return GenerateDefault_generateLife (solarSys, world, whichNode); + return GenerateDefault_generateLife (solarSys, world, whichNode, info); } static bool Modified: trunk/sc2/src/uqm/planets/generate/genwreck.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genwreck.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genwreck.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -27,8 +27,8 @@ static bool GenerateWreck_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateWreck_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateWreck_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateWreck_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -73,12 +73,12 @@ } static COUNT -GenerateWreck_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateWreck_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 6, MATCH_PLANET)) { - return GenerateDefault_generateArtifact (solarSys, whichNode); + return GenerateDefault_generateArtifact (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genyeh.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genyeh.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genyeh.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -30,8 +30,8 @@ static bool GenerateYehat_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateYehat_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateYehat_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateYehat_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateYehat_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -113,12 +113,12 @@ } static COUNT -GenerateYehat_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateYehat_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genzoq.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genzoq.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate/genzoq.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -30,8 +30,8 @@ static bool GenerateZoqFotPik_generatePlanets (SOLARSYS_STATE *solarSys); static bool GenerateZoqFotPik_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world); -static COUNT GenerateZoqFotPik_generateEnergy (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +static COUNT GenerateZoqFotPik_generateEnergy (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); static bool GenerateZoqFotPik_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode); @@ -143,12 +143,12 @@ } static COUNT -GenerateZoqFotPik_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT whichNode) +GenerateZoqFotPik_generateEnergy (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info) { if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { - return GenerateDefault_generateRuins (solarSys, whichNode); + return GenerateDefault_generateRuins (solarSys, whichNode, info); } return 0; Modified: trunk/sc2/src/uqm/planets/generate.h =================================================================== --- trunk/sc2/src/uqm/planets/generate.h 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/generate.h 2011-09-09 21:36:34 UTC (rev 3695) @@ -56,16 +56,16 @@ PLANET_DESC *planet); typedef bool (*GenerateOrbitalFunction)(SOLARSYS_STATE *solarSys, PLANET_DESC *world); -typedef bool (*GenerateNameFunction)(SOLARSYS_STATE *solarSys, - PLANET_DESC *world); +typedef bool (*GenerateNameFunction)(const SOLARSYS_STATE *, + const PLANET_DESC *world); // The following functions return the number of objects being generated // (or the index of the current object in some cases) -typedef COUNT (*GenerateMineralsFunction)(SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); -typedef COUNT (*GenerateEnergyFunction)(SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); -typedef COUNT (*GenerateLifeFunction)(SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT whichNode); +typedef COUNT (*GenerateMineralsFunction)(const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); +typedef COUNT (*GenerateEnergyFunction)(const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); +typedef COUNT (*GenerateLifeFunction)(const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT whichNode, NODE_INFO *); // The following functions return true if the node should be removed // from the surface, i.e. picked up. typedef bool (*PickupMineralsFunction)(SOLARSYS_STATE *solarSys, Modified: trunk/sc2/src/uqm/planets/plandata.h =================================================================== --- trunk/sc2/src/uqm/planets/plandata.h 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/plandata.h 2011-09-09 21:36:34 UTC (rev 3695) @@ -279,25 +279,6 @@ DWORD ScanSeed[NUM_SCAN_TYPES]; DWORD ScanRetrieveMask[NUM_SCAN_TYPES]; - // The CurPt, CurDensity and CurType fields are filled in - // when a GENERATE_MINERAL, GENERATE_ENERGY, or GENERATE_LIFE - // call is made. - POINT CurPt; - // Position of the mineral/bio/energy node on the planet. - COUNT CurDensity; - // For bio and energy: undefined - // For minerals the low byte is the gross size of the - // deposit (this determines the image), and the high - // byte is the fine size (the actual quantity). - COUNT CurType; - // For minerals: the type of element - // For bio: the type of the creature. - // 0 through NUM_CREATURE_TYPES - 1 are normal creatures, - // NUM_CREATURE_TYPES is an Evil One - // NUM_CREATURE_TYPES + 1 is a Brainbox Bulldozer - // NUM_CREATURE_TYPES + 2 is Zex' Beauty - // For energy: undefined - STRING DiscoveryString; FONT LanderFont; FRAME LanderFontEff; Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/planets.h 2011-09-09 21:36:34 UTC (rev 3695) @@ -88,6 +88,7 @@ typedef struct planet_desc PLANET_DESC; typedef struct star_desc STAR_DESC; +typedef struct node_info NODE_INFO; typedef struct planet_orbit PLANET_ORBIT; typedef struct solarsys_state SOLARSYS_STATE; @@ -131,7 +132,26 @@ BYTE Postfix; }; -typedef void (*PLAN_GEN_FUNC) (BYTE control); +struct node_info +{ + // This structire is filled in when a generateMinerals, generateEnergy, + // or generateLife call is made. + POINT loc_pt; + // Position of the mineral/bio/energy node on the planet. + COUNT density; + // For bio and energy: undefined + // For minerals the low byte is the gross size of the + // deposit (this determines the image), and the high + // byte is the fine size (the actual quantity). + COUNT type; + // For minerals: the type of element + // For bio: the type of the creature. + // 0 through NUM_CREATURE_TYPES - 1 are normal creatures, + // NUM_CREATURE_TYPES is an Evil One + // NUM_CREATURE_TYPES + 1 is a Brainbox Bulldozer + // NUM_CREATURE_TYPES + 2 is Zex' Beauty + // For energy: undefined +}; struct planet_orbit { @@ -264,7 +284,6 @@ extern void ExploreSolarSys (void); extern void DrawStarBackGround (void); extern void XFormIPLoc (POINT *pIn, POINT *pOut, BOOLEAN ToDisplay); -extern PLAN_GEN_FUNC GenerateIP (BYTE Index); extern void DrawOval (RECT *pRect, BYTE num_off_pixels); extern void DrawFilledOval (RECT *pRect); extern void FillOrbits (SOLARSYS_STATE *system, BYTE NumPlanets, Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/scan.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -935,20 +935,20 @@ } COUNT -callGenerateForScanType (SOLARSYS_STATE *solarSys, PLANET_DESC *world, - COUNT node, BYTE scanType) +callGenerateForScanType (const SOLARSYS_STATE *solarSys, + const PLANET_DESC *world, COUNT node, BYTE scanType, NODE_INFO *info) { switch (scanType) { case MINERAL_SCAN: return (*solarSys->genFuncs->generateMinerals) ( - solarSys, world, node); + solarSys, world, node, info); case ENERGY_SCAN: return (*solarSys->genFuncs->generateEnergy) ( - solarSys, world, node); + solarSys, world, node, info); case BIOLOGICAL_SCAN: return (*solarSys->genFuncs->generateLife) ( - solarSys, world, node); + solarSys, world, node, info); } assert (false); @@ -1293,19 +1293,16 @@ static void generateBioNode (SOLARSYS_STATE *system, ELEMENT *NodeElementPtr, - BYTE *life_init_tab) + BYTE *life_init_tab, COUNT creatureType) { COUNT i; - COUNT creatureType; - creatureType = system->SysInfo.PlanetInfo.CurType; - // NOTE: TFB_Random() calls here are NOT part of the deterministic planet // generation PRNG flow. if (CreatureData[creatureType].Attributes & SPEED_MASK) { // Place moving creatures at a random location. - i = (COUNT)TFB_Random (); + i = TFB_Random (); NodeElementPtr->current.location.x = (LOBYTE (i) % (MAP_WIDTH - (8 << 1))) + 8; NodeElementPtr->current.location.y = @@ -1361,12 +1358,13 @@ NUM_SCANDOT_TRANSITIONS * (scan - ENERGY_SCAN)); num_nodes = callGenerateForScanType (pSolarSysState, - pSolarSysState->pOrbitalDesc, ~0, scan); + pSolarSysState->pOrbitalDesc, GENERATE_ALL, scan, NULL); while (num_nodes--) { HELEMENT hNodeElement; ELEMENT *NodeElementPtr; + NODE_INFO info; if (isNodeRetrieved (&pSolarSysState->SysInfo.PlanetInfo, scan, num_nodes)) @@ -1380,30 +1378,24 @@ callGenerateForScanType (pSolarSysState, pSolarSysState->pOrbitalDesc, num_nodes, - scan); + scan, &info); NodeElementPtr->scan_node = MAKE_WORD (scan, num_nodes + 1); NodeElementPtr->playerNr = PS_NON_PLAYER; - NodeElementPtr->current.location.x = - pSolarSysState->SysInfo.PlanetInfo.CurPt.x; - NodeElementPtr->current.location.y = - pSolarSysState->SysInfo.PlanetInfo.CurPt.y; + NodeElementPtr->current.location.x = info.loc_pt.x; + NodeElementPtr->current.location.y = info.loc_pt.y; SetPrimType (&DisplayArray[NodeElementPtr->PrimIndex], STAMP_PRIM); if (scan == MINERAL_SCAN) { - COUNT EType; - - EType = pSolarSysState->SysInfo.PlanetInfo.CurType; - NodeElementPtr->turn_wait = (BYTE)EType; - NodeElementPtr->mass_points = HIBYTE ( - pSolarSysState->SysInfo.PlanetInfo.CurDensity); + NodeElementPtr->turn_wait = info.type; + NodeElementPtr->mass_points = HIBYTE (info.density); NodeElementPtr->current.image.frame = SetAbsFrameIndex ( MiscDataFrame, (NUM_SCANDOT_TRANSITIONS * 2) - + ElementCategory (EType) * 5); + + ElementCategory (info.type) * 5); NodeElementPtr->next.image.frame = SetRelFrameIndex ( - NodeElementPtr->current.image.frame, LOBYTE ( - pSolarSysState->SysInfo.PlanetInfo.CurDensity) + 1); + NodeElementPtr->current.image.frame, + LOBYTE (info.density) + 1); DisplayArray[NodeElementPtr->PrimIndex].Object.Stamp.frame = IncFrameIndex (NodeElementPtr->next.image.frame); } @@ -1423,7 +1415,7 @@ else /* (scan == BIOLOGICAL_SCAN) */ { generateBioNode (pSolarSysState, NodeElementPtr, - life_init_tab); + life_init_tab, info.type); } } Modified: trunk/sc2/src/uqm/planets/scan.h =================================================================== --- trunk/sc2/src/uqm/planets/scan.h 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/scan.h 2011-09-09 21:36:34 UTC (rev 3695) @@ -50,8 +50,8 @@ extern void RepairBackRect (RECT *pRect); extern void GeneratePlanetSide (void); -extern COUNT callGenerateForScanType (SOLARSYS_STATE *solarSys, - PLANET_DESC *world, COUNT node, BYTE scanType); +extern COUNT callGenerateForScanType (const SOLARSYS_STATE *, + const PLANET_DESC *world, COUNT node, BYTE scanType, NODE_INFO *); // Returns true if the node should be removed from the surface extern bool callPickupForScanType (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT node, BYTE scanType); Modified: trunk/sc2/src/uqm/planets/sundata.h =================================================================== --- trunk/sc2/src/uqm/planets/sundata.h 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/sundata.h 2011-09-09 21:36:34 UTC (rev 3695) @@ -45,12 +45,16 @@ #define GENERATE_ALL ((COUNT)~0) -extern COUNT GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr, - COUNT whichDeposit); -extern COUNT GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT whichLife); -extern void GenerateRandomLocation (SYSTEM_INFO *); -extern COUNT GenerateRandomNodes (SYSTEM_INFO *, COUNT scan, COUNT numNodes, - COUNT type, COUNT whichNode); +extern COUNT GenerateMineralDeposits (const SYSTEM_INFO *, COUNT whichDeposit, + NODE_INFO *info); +extern COUNT GenerateLifeForms (const SYSTEM_INFO *, COUNT whichLife, + NODE_INFO *info); +extern void GenerateRandomLocation (POINT *loc); +extern COUNT GenerateRandomNodes (const SYSTEM_INFO *, COUNT scan, COUNT numNodes, + COUNT type, COUNT whichNode, NODE_INFO *info); +// Generate lifeforms from a preset lifeTypes[] array +extern COUNT GeneratePresetLife (const SYSTEM_INFO *, + const SBYTE *lifeTypes, COUNT whichLife, NODE_INFO *info); #define DWARF_ELEMENT_DENSITY 1 #define GIANT_ELEMENT_DENSITY 3 Modified: trunk/sc2/src/uqm/planets/surface.c =================================================================== --- trunk/sc2/src/uqm/planets/surface.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/planets/surface.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -28,7 +28,8 @@ const PlanetFrame *PlanData; static COUNT -CalcMineralDeposits (SYSTEM_INFO *SysInfoPtr, COUNT which_deposit) +CalcMineralDeposits (const SYSTEM_INFO *SysInfoPtr, COUNT which_deposit, + NODE_INFO *info) { BYTE j; COUNT num_deposits; @@ -62,27 +63,26 @@ else deposit_quality_gross = 2; - GenerateRandomLocation (SysInfoPtr); + GenerateRandomLocation (&info->loc_pt); - SysInfoPtr->PlanetInfo.CurDensity = - MAKE_WORD ( - deposit_quality_gross, deposit_quality_fine / 10 + 1 - ); - SysInfoPtr->PlanetInfo.CurType = eptr->ElementType; + info->density = MAKE_WORD ( + deposit_quality_gross, deposit_quality_fine / 10 + 1); + info->type = eptr->ElementType; #ifdef DEBUG_SURFACE log_add (log_Debug, "\t\t%d units of %Fs", - SysInfoPtr->PlanetInfo.CurDensity, + info->density, Elements[eptr->ElementType].name); #endif /* DEBUG_SURFACE */ if (num_deposits >= which_deposit || ++num_deposits == sizeof (DWORD) * 8) - goto ExitCalcMinerals; + { // reached the maximum or the requested node + return num_deposits; + } } ++eptr; } while (--j); -ExitCalcMinerals: - return (num_deposits); + return num_deposits; } // Returns: @@ -90,15 +90,20 @@ // for whichLife<32 : the index of the last node (no known usage exists) // Sets the SysGenRNG to the required state first. COUNT -GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr, COUNT whichDeposit) +GenerateMineralDeposits (const SYSTEM_INFO *SysInfoPtr, COUNT whichDeposit, + NODE_INFO *info) { + NODE_INFO temp_info; + if (!info) // user not interested in info but we need space for it + info = &temp_info; RandomContext_SeedRandom (SysGenRNG, SysInfoPtr->PlanetInfo.ScanSeed[MINERAL_SCAN]); - return CalcMineralDeposits (SysInfoPtr, whichDeposit); + return CalcMineralDeposits (SysInfoPtr, whichDeposit, info); } static COUNT -CalcLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT which_life) +CalcLifeForms (const SYSTEM_INFO *SysInfoPtr, COUNT which_life, + NODE_INFO *info) { COUNT num_life_forms; @@ -127,26 +132,28 @@ num_creatures = 1 + HIBYTE (rand_val) % 10; do { - GenerateRandomLocation (SysInfoPtr); - SysInfoPtr->PlanetInfo.CurType = index; + GenerateRandomLocation (&info->loc_pt); + info->type = index; + info->density = 0; if (num_life_forms >= which_life || ++num_life_forms == sizeof (DWORD) * 8) - { - num_types = 1; - break; + { // reached the maximum or the requested node + return num_life_forms; } } while (--num_creatures); } while (--num_types); } #ifdef DEBUG_SURFACE else + { log_add (log_Debug, "It's dead, Jim! (%d >= %d)", life_var, SysInfoPtr->PlanetInfo.LifeChance); + } #endif /* DEBUG_SURFACE */ } - return (num_life_forms); + return num_life_forms; } // Returns: @@ -154,23 +161,61 @@ // for whichLife<32 : the index of the last lifeform (no known usage exists) // Sets the SysGenRNG to the required state first. COUNT -GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT whichLife) +GenerateLifeForms (const SYSTEM_INFO *SysInfoPtr, COUNT whichLife, + NODE_INFO *info) { + NODE_INFO temp_info; + if (!info) // user not interested in info but we need space for it + info = &temp_info; RandomContext_SeedRandom (SysGenRNG, SysInfoPtr->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); - return CalcLifeForms (SysInfoPtr, whichLife); + return CalcLifeForms (SysInfoPtr, whichLife, info); } +// Returns: +// for whichLife==~0 : the number of lifeforms generated +// for whichLife<32 : the index of the last lifeform (no known usage exists) +// Sets the SysGenRNG to the required state first. +// lifeTypes[] is terminated with -1 +COUNT +GeneratePresetLife (const SYSTEM_INFO *SysInfoPtr, const SBYTE *lifeTypes, + COUNT whichLife, NODE_INFO *info) +{ + COUNT i; + NODE_INFO temp_info; + + if (!info) // user not interested in info but we need space for it + info = &temp_info; + + // This function may look unnecessarily complicated, but it must be + // kept this way to preserve the universe. That is done by preserving + // the order and number of Random() calls. + + RandomContext_SeedRandom (SysGenRNG, + SysInfoPtr->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); + + for (i = 0; lifeTypes[i] >= 0; ++i) + { + GenerateRandomLocation (&info->loc_pt); + info->type = lifeTypes[i]; + // density is irrelevant for bio nodes + info->density = 0; + + if (i >= whichLife) + break; + } + + return i; +} + void -GenerateRandomLocation (SYSTEM_INFO *SysInfoPtr) +GenerateRandomLocation (POINT *loc) { UWORD rand_val; rand_val = RandomContext_Random (SysGenRNG); - SysInfoPtr->PlanetInfo.CurPt.x = - (LOBYTE (rand_val) % (MAP_WIDTH - (8 << 1))) + 8; - SysInfoPtr->PlanetInfo.CurPt.y = - (HIBYTE (rand_val) % (MAP_HEIGHT - (8 << 1))) + 8; + loc->x = 8 + LOBYTE (rand_val) % (MAP_WIDTH - (8 << 1)); + loc->y = 8 + HIBYTE (rand_val) % (MAP_HEIGHT - (8 << 1)); } // Returns: @@ -178,20 +223,25 @@ // for whichNode<32 : the index of the last node (no known usage exists) // Sets the SysGenRNG to the required state first. COUNT -GenerateRandomNodes (SYSTEM_INFO *SysInfoPtr, COUNT scan, COUNT numNodes, - COUNT type, COUNT whichNode) +GenerateRandomNodes (const SYSTEM_INFO *SysInfoPtr, COUNT scan, COUNT numNodes, + COUNT type, COUNT whichNode, NODE_INFO *info) { COUNT i; + NODE_INFO temp_info; - RandomContext_SeedRandom (SysGenRNG, SysInfoPtr->PlanetInfo.ScanSeed[scan]); + if (!info) // user not interested in info but we need space for it + info = &temp_info; + RandomContext_SeedRandom (SysGenRNG, + SysInfoPtr->PlanetInfo.ScanSeed[scan]); + for (i = 0; i < numNodes; ++i) { - GenerateRandomLocation (SysInfoPtr); - // CurType is irrelevant for energy nodes - SysInfoPtr->PlanetInfo.CurType = type; - // CurDensity is irrelevant for energy and bio nodes - SysInfoPtr->PlanetInfo.CurDensity = 0; + GenerateRandomLocation (&info->loc_pt); + // type is irrelevant for energy nodes + info->type = type; + // density is irrelevant for energy and bio nodes + info->density = 0; if (i >= whichNode) break; Modified: trunk/sc2/src/uqm/uqmdebug.c =================================================================== --- trunk/sc2/src/uqm/uqmdebug.c 2011-09-09 01:59:12 UTC (rev 3694) +++ trunk/sc2/src/uqm/uqmdebug.c 2011-09-09 21:36:34 UTC (rev 3695) @@ -973,8 +973,7 @@ void dumpPlanet (FILE *out, const PLANET_DESC *planet) { - (*pSolarSysState->genFuncs->generateName) ( - pSolarSysState, (PLANET_DESC *) planet); + (*pSolarSysState->genFuncs->generateName) (pSolarSysState, planet); fprintf (out, "- %-37s %s\n", GLOBAL_SIS (PlanetName), planetTypeString (planet->data_index & ~PLANET_SHIELDED)); dumpWorld (out, planet); @@ -1055,16 +1054,16 @@ assert (system->pOrbitalDesc == world); - numBio = callGenerateForScanType ((SOLARSYS_STATE *) system, - (PLANET_DESC *) world, ~0, BIOLOGICAL_SCAN); + numBio = callGenerateForScanType (system, world, GENERATE_ALL, + BIOLOGICAL_SCAN, NULL); result = 0; for (i = 0; i < numBio; i++) { - callGenerateForScanType ((SOLARSYS_STATE *) system, - (PLANET_DESC *) world, i, BIOLOGICAL_SCAN); - result += BIO_CREDIT_VALUE * LONIBBLE (CreatureData[ - system->SysInfo.PlanetInfo.CurType].ValueAndHitPoints); + NODE_INFO info; + callGenerateForScanType (system, world, i, BIOLOGICAL_SCAN, &info); + result += BIO_CREDIT_VALUE * + LONIBBLE (CreatureData[info.type].ValueAndHitPoints); } return result; } @@ -1078,17 +1077,17 @@ assert (system->pOrbitalDesc == world); - numBio = callGenerateForScanType ((SOLARSYS_STATE *) system, - (PLANET_DESC *) world, ~0, BIOLOGICAL_SCAN); + numBio = callGenerateForScanType (system, world, GENERATE_ALL, + BIOLOGICAL_SCAN, NULL); for (i = 0; i < NUM_CREATURE_TYPES + NUM_SPECIAL_CREATURE_TYPES; i++) bio[i] = 0; for (i = 0; i < numBio; i++) { - callGenerateForScanType ((SOLARSYS_STATE *) system, - (PLANET_DESC *) world, i, BIOLOGICAL_SCAN); - bio[system->SysInfo.PlanetInfo.CurType]++; + NODE_INFO info; + callGenerateForScanType (system, world, i, BIOLOGICAL_SCAN, &info); + bio[info.type]++; } } @@ -1101,17 +1100,16 @@ assert (system->pOrbitalDesc == world); - numDeposits = callGenerateForScanType ((SOLARSYS_STATE *) system, - (PLANET_DESC *) world, ~0, MINERAL_SCAN); + numDeposits = callGenerateForScanType (system, world, GENERATE_ALL, + MINERAL_SCAN, NULL); result = 0; for (i = 0; i < numDeposits; i++) { - callGenerateForScanType ((SOLARSYS_STATE *) system, - (PLANET_DESC *) world, i, MINERAL_SCAN); - result += HIBYTE (system->SysInfo.PlanetInfo.CurDensity) * - GLOBAL (ElementWorth[ElementCategory ( - system->SysInfo.PlanetInfo.CurType)]); + NODE_INFO info; + callGenerateForScanType (system, world, i, MINERAL_SCAN, &info); + result += HIBYTE (info.density) * + GLOBAL (ElementWorth[ElementCategory (info.type)]); } return result; } @@ -1125,18 +1123,17 @@ assert (system->pOrbitalDesc == world); - ... [truncated message content] |
From: <av...@us...> - 2011-09-09 01:59:20
|
Revision: 3694 http://sc2.svn.sourceforge.net/sc2/?rev=3694&view=rev Author: avolkov Date: 2011-09-09 01:59:12 +0000 (Fri, 09 Sep 2011) Log Message: ----------- Planet/system generation code cleanup: isolate generation code with an own RandomContext; generation funcs do not return the random seed anymore; move and cleanup some calculation funcs; clarify deliberate Random() truncation; other random cleanups Modified Paths: -------------- trunk/sc2/build/msvc6/UrQuanMasters.dsp trunk/sc2/src/libs/math/random.h trunk/sc2/src/libs/math/random2.c trunk/sc2/src/uqm/Makeinfo trunk/sc2/src/uqm/comm.c trunk/sc2/src/uqm/encount.c trunk/sc2/src/uqm/encount.h trunk/sc2/src/uqm/gameev.c trunk/sc2/src/uqm/gameopt.c trunk/sc2/src/uqm/gendef.c trunk/sc2/src/uqm/gendef.h trunk/sc2/src/uqm/globdata.c trunk/sc2/src/uqm/grpinfo.c trunk/sc2/src/uqm/hyper.c trunk/sc2/src/uqm/load.c trunk/sc2/src/uqm/plandata.c trunk/sc2/src/uqm/planets/calc.c trunk/sc2/src/uqm/planets/devices.c trunk/sc2/src/uqm/planets/generate/genburv.c trunk/sc2/src/uqm/planets/generate/genchmmr.c trunk/sc2/src/uqm/planets/generate/gendefault.c trunk/sc2/src/uqm/planets/generate/genmel.c trunk/sc2/src/uqm/planets/generate/genmyc.c trunk/sc2/src/uqm/planets/generate/genorz.c trunk/sc2/src/uqm/planets/generate/genpet.c trunk/sc2/src/uqm/planets/generate/genrain.c trunk/sc2/src/uqm/planets/generate/gensam.c trunk/sc2/src/uqm/planets/generate/gensol.c trunk/sc2/src/uqm/planets/generate/genspa.c trunk/sc2/src/uqm/planets/generate/genthrad.c trunk/sc2/src/uqm/planets/generate/genutw.c trunk/sc2/src/uqm/planets/generate/genvux.c trunk/sc2/src/uqm/planets/gentopo.c trunk/sc2/src/uqm/planets/lander.c trunk/sc2/src/uqm/planets/orbits.c trunk/sc2/src/uqm/planets/plandata.h trunk/sc2/src/uqm/planets/planets.h trunk/sc2/src/uqm/planets/plangen.c trunk/sc2/src/uqm/planets/pstarmap.c trunk/sc2/src/uqm/planets/scan.c trunk/sc2/src/uqm/planets/solarsys.c trunk/sc2/src/uqm/planets/sundata.h trunk/sc2/src/uqm/planets/surface.c trunk/sc2/src/uqm/restart.c trunk/sc2/src/uqm/save.c trunk/sc2/src/uqm/sis.c trunk/sc2/src/uqm/starbase.c trunk/sc2/src/uqm/starmap.c trunk/sc2/src/uqm/state.c trunk/sc2/src/uqm/uqmdebug.c Added Paths: ----------- trunk/sc2/src/uqm/starmap.h Modified: trunk/sc2/build/msvc6/UrQuanMasters.dsp =================================================================== --- trunk/sc2/build/msvc6/UrQuanMasters.dsp 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/build/msvc6/UrQuanMasters.dsp 2011-09-09 01:59:12 UTC (rev 3694) @@ -3482,6 +3482,10 @@ # End Source File # Begin Source File +SOURCE=..\..\src\uqm\starmap.h +# End Source File +# Begin Source File + SOURCE=..\..\src\uqm\state.c # End Source File # Begin Source File Modified: trunk/sc2/src/libs/math/random.h =================================================================== --- trunk/sc2/src/libs/math/random.h 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/libs/math/random.h 2011-09-09 01:59:12 UTC (rev 3694) @@ -29,13 +29,6 @@ #ifndef _RANDOM_H #define _RANDOM_H -/* ----------------------------DEFINES------------------------------------ */ - -#define RAND(n) ( (int) ( (unsigned int)TFB_Random() % (n) ) ) -#define SRAND(n) ( (int)TFB_Random() % (n) ) -#define AND_RAND(n) ( (int)TFB_Random() & (n) ) - - /* ----------------------------GLOBALS/EXTERNS---------------------------- */ DWORD TFB_SeedRandom (DWORD seed); @@ -55,6 +48,7 @@ RandomContext *RandomContext_Copy (const RandomContext *source); DWORD RandomContext_Random (RandomContext *context); DWORD RandomContext_SeedRandom (RandomContext *context, DWORD new_seed); +DWORD RandomContext_GetSeed (RandomContext *context); #endif /* _RANDOM_H */ Modified: trunk/sc2/src/libs/math/random2.c =================================================================== --- trunk/sc2/src/libs/math/random2.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/libs/math/random2.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -82,4 +82,8 @@ return old_seed; } - +DWORD +RandomContext_GetSeed (RandomContext *context) +{ + return context->seed; +} Modified: trunk/sc2/src/uqm/Makeinfo =================================================================== --- trunk/sc2/src/uqm/Makeinfo 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/Makeinfo 2011-09-09 01:59:12 UTC (rev 3694) @@ -18,5 +18,6 @@ nameref.h oscill.h pickship.h process.h races.h resinst.h respkg.h restart.h save.h settings.h setup.h setupmenu.h shipcont.h ship.h sis.h sounds.h starbase.h starcon.h state.h status.h tactrans.h + starmap.h units.h uqmdebug.h util.h velocity.h weapon.h" Modified: trunk/sc2/src/uqm/comm.c =================================================================== --- trunk/sc2/src/uqm/comm.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/comm.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -27,6 +27,7 @@ #include "sis.h" #include "units.h" #include "encount.h" +#include "starmap.h" #include "endian_uqm.h" #include "gamestr.h" #include "options.h" Modified: trunk/sc2/src/uqm/encount.c =================================================================== --- trunk/sc2/src/uqm/encount.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/encount.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -22,6 +22,7 @@ #include "battlecontrols.h" #include "build.h" #include "colors.h" +#include "starmap.h" #include "cons_res.h" #include "controls.h" #include "menustat.h" Modified: trunk/sc2/src/uqm/encount.h =================================================================== --- trunk/sc2/src/uqm/encount.h 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/encount.h 2011-09-09 01:59:12 UTC (rev 3694) @@ -95,76 +95,10 @@ enum { - SOL_DEFINED = 1, - SHOFIXTI_DEFINED, - MAIDENS_DEFINED, - START_COLONY_DEFINED, - SPATHI_DEFINED, - ZOQFOT_DEFINED, - - MELNORME0_DEFINED, - MELNORME1_DEFINED, - MELNORME2_DEFINED, - MELNORME3_DEFINED, - MELNORME4_DEFINED, - MELNORME5_DEFINED, - MELNORME6_DEFINED, - MELNORME7_DEFINED, - MELNORME8_DEFINED, - - TALKING_PET_DEFINED, - CHMMR_DEFINED, - SYREEN_DEFINED, - BURVIXESE_DEFINED, - SLYLANDRO_DEFINED, - DRUUGE_DEFINED, - BOMB_DEFINED, - AQUA_HELIX_DEFINED, - SUN_DEVICE_DEFINED, - TAALO_PROTECTOR_DEFINED, - SHIP_VAULT_DEFINED, - URQUAN_WRECK_DEFINED, - VUX_BEAST_DEFINED, - SAMATRA_DEFINED, - ZOQ_SCOUT_DEFINED, - MYCON_DEFINED, - EGG_CASE0_DEFINED, - EGG_CASE1_DEFINED, - EGG_CASE2_DEFINED, - PKUNK_DEFINED, - UTWIG_DEFINED, - SUPOX_DEFINED, - YEHAT_DEFINED, - VUX_DEFINED, - ORZ_DEFINED, - THRADD_DEFINED, - RAINBOW_DEFINED, - ILWRATH_DEFINED, - ANDROSYNTH_DEFINED, - MYCON_TRAP_DEFINED -}; - -#define UMGAH_DEFINED TALKING_PET_DEFINED - -// XXX: The stuff till EOC does not belong here -extern STAR_DESC *CurStarDescPtr; -extern STAR_DESC *star_array; - -#define NUM_SOLAR_SYSTEMS 502 - -extern STAR_DESC* FindStar (STAR_DESC *pLastStar, POINT *puniverse, - SIZE xbounds, SIZE ybounds); - -extern void GetClusterName (const STAR_DESC *pSD, UNICODE buf[]); -// <<< EOC - -enum -{ HAIL = 0, ATTACK }; - extern void EncounterBattle (void); extern void BuildBattle (COUNT which_player); extern COUNT InitEncounter (void); @@ -172,35 +106,6 @@ extern BOOLEAN FleetIsInfinite (COUNT playerNr); extern void UpdateShipFragCrew (STARSHIP *); -// XXX: in comm.h, temporary, until solsys generation code is redone -extern COUNT InitCommunication (CONVERSATION which_comm); - -extern void GenerateSOL (BYTE control); -extern void GenerateShofixti (BYTE control); -extern void GenerateColony (BYTE control); -extern void GenerateSpathi (BYTE control); -extern void GenerateZoqFotPik (BYTE control); -extern void GenerateMelnorme (BYTE control); -extern void GenerateTalkingPet (BYTE control); -extern void GenerateChmmr (BYTE control); -extern void GenerateSyreen (BYTE control); -extern void GenerateBurvixes (BYTE control); -extern void GenerateSlylandro (BYTE control); -extern void GenerateDruuge (BYTE control); -extern void GenerateUtwig (BYTE control); -extern void GenerateThradd (BYTE control); -extern void GenerateMycon (BYTE control); -extern void GenerateOrz (BYTE control); -extern void GenerateShipVault (BYTE control); -extern void GenerateUrquanWreck (BYTE control); -extern void GenerateVUX (BYTE control); -extern void GenerateSamatra (BYTE control); -extern void GenerateYehat (BYTE control); -extern void GeneratePkunk (BYTE control); -extern void GenerateSupox (BYTE control); -extern void GenerateRainbow (BYTE control); -extern void GenerateIlwrath (BYTE control); - // Last race the player battled with, or -1 if no battle took place. // Set to -1 by some funcs to inhibit IP groups from intercepting // the flagship. Modified: trunk/sc2/src/uqm/gameev.c =================================================================== --- trunk/sc2/src/uqm/gameev.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/gameev.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -19,8 +19,8 @@ #include "build.h" #include "clock.h" -// XXX: for CurStarDescPtr and XXX_DEFINED constants -#include "encount.h" +#include "starmap.h" +#include "gendef.h" #include "globdata.h" #include "hyper.h" #include "libs/compiler.h" Modified: trunk/sc2/src/uqm/gameopt.c =================================================================== --- trunk/sc2/src/uqm/gameopt.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/gameopt.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -21,8 +21,7 @@ #include "build.h" #include "colors.h" #include "controls.h" -// XXX: for FindStart(), GetClusterName() -#include "encount.h" +#include "starmap.h" #include "menustat.h" #include "sis.h" #include "units.h" Modified: trunk/sc2/src/uqm/gendef.c =================================================================== --- trunk/sc2/src/uqm/gendef.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/gendef.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -17,7 +17,6 @@ */ #include "gendef.h" -#include "encount.h" #include "planets/generate.h" Modified: trunk/sc2/src/uqm/gendef.h =================================================================== --- trunk/sc2/src/uqm/gendef.h 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/gendef.h 2011-09-09 01:59:12 UTC (rev 3694) @@ -10,6 +10,59 @@ const GenerateFunctions *getGenerateFunctions (BYTE Index); +enum +{ + SOL_DEFINED = 1, + SHOFIXTI_DEFINED, + MAIDENS_DEFINED, + START_COLONY_DEFINED, + SPATHI_DEFINED, + ZOQFOT_DEFINED, + + MELNORME0_DEFINED, + MELNORME1_DEFINED, + MELNORME2_DEFINED, + MELNORME3_DEFINED, + MELNORME4_DEFINED, + MELNORME5_DEFINED, + MELNORME6_DEFINED, + MELNORME7_DEFINED, + MELNORME8_DEFINED, + + TALKING_PET_DEFINED, + CHMMR_DEFINED, + SYREEN_DEFINED, + BURVIXESE_DEFINED, + SLYLANDRO_DEFINED, + DRUUGE_DEFINED, + BOMB_DEFINED, + AQUA_HELIX_DEFINED, + SUN_DEVICE_DEFINED, + TAALO_PROTECTOR_DEFINED, + SHIP_VAULT_DEFINED, + URQUAN_WRECK_DEFINED, + VUX_BEAST_DEFINED, + SAMATRA_DEFINED, + ZOQ_SCOUT_DEFINED, + MYCON_DEFINED, + EGG_CASE0_DEFINED, + EGG_CASE1_DEFINED, + EGG_CASE2_DEFINED, + PKUNK_DEFINED, + UTWIG_DEFINED, + SUPOX_DEFINED, + YEHAT_DEFINED, + VUX_DEFINED, + ORZ_DEFINED, + THRADD_DEFINED, + RAINBOW_DEFINED, + ILWRATH_DEFINED, + ANDROSYNTH_DEFINED, + MYCON_TRAP_DEFINED +}; + +#define UMGAH_DEFINED TALKING_PET_DEFINED + #if defined(__cplusplus) } #endif Modified: trunk/sc2/src/uqm/globdata.c =================================================================== --- trunk/sc2/src/uqm/globdata.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/globdata.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -20,6 +20,7 @@ #include "coderes.h" #include "encount.h" +#include "starmap.h" #include "master.h" #include "setup.h" #include "units.h" Modified: trunk/sc2/src/uqm/grpinfo.c =================================================================== --- trunk/sc2/src/uqm/grpinfo.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/grpinfo.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -17,8 +17,8 @@ */ #include "build.h" -// XXX: for CurStarDescPtr and XXX_DEFINED constants -#include "encount.h" +#include "starmap.h" +#include "gendef.h" #include "libs/file.h" #include "globdata.h" #include "intel.h" Modified: trunk/sc2/src/uqm/hyper.c =================================================================== --- trunk/sc2/src/uqm/hyper.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/hyper.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -26,6 +26,7 @@ #include "menustat.h" // for DrawMenuStateStrings() #include "encount.h" +#include "starmap.h" #include "ship.h" #include "shipcont.h" #include "process.h" Modified: trunk/sc2/src/uqm/load.c =================================================================== --- trunk/sc2/src/uqm/load.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/load.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -23,6 +23,7 @@ #include "build.h" #include "libs/declib.h" #include "encount.h" +#include "starmap.h" #include "libs/file.h" #include "globdata.h" #include "load.h" Modified: trunk/sc2/src/uqm/plandata.c =================================================================== --- trunk/sc2/src/uqm/plandata.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/plandata.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -16,8 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// XXX: for XXX_DEFINED constants -#include "encount.h" +#include "gendef.h" #include "resinst.h" #include "planets/planets.h" #include "planets/elemdata.h" Modified: trunk/sc2/src/uqm/planets/calc.c =================================================================== --- trunk/sc2/src/uqm/planets/calc.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/calc.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -17,7 +17,8 @@ */ /* ----------------------------- INCLUDES ---------------------------- */ -#include "../encount.h" +#include "planets.h" +#include "uqm/starmap.h" #include "libs/mathlib.h" #include "libs/log.h" /* -------------------------------- DATA -------------------------------- */ @@ -26,9 +27,6 @@ //#define DEBUG_PLANET_CALC -#define CalcMass(b) CalcFromBase (b, b) -#define CalcRadius(b) CalcFromBase (b, ((b) >> 1) + 1) - #define LOW_TEMP 0 #define MED_TEMP 500 #define HIGH_TEMP 1500 @@ -36,15 +34,6 @@ #define MED_TEMP_BONUS 25 #define HIGH_TEMP_BONUS 50 #define MAX_TECTONICS 255 -#ifdef OLD -#define CalcTectonics(b,t) (CalcFromBase(b, 3 << 5) \ - + (UWORD)((t) < LOW_TEMP ? 0 : \ - ((t) < MED_TEMP ? LOW_TEMP_BONUS : \ - ((t) < HIGH_TEMP ? MED_TEMP_BONUS : \ - HIGH_TEMP_BONUS)))) -#else /* OLD */ -#define CalcTectonics(b,t) CalcFromBase(b, 3 << 5) -#endif /* OLD */ enum { @@ -56,6 +45,18 @@ WHITE_SUN_INTENSITY }; +static UWORD +CalcFromBase (UWORD base, UWORD variance) +{ + return base + LOWORD (RandomContext_Random (SysGenRNG)) % variance; +} + +static inline UWORD +CalcHalfBaseVariance (UWORD base) +{ + return CalcFromBase (base, (base >> 1) + 1); +} + static void CalcSysInfo (SYSTEM_INFO *SysInfoPtr) { @@ -149,7 +150,7 @@ PlanetInfoPtr->Weather += 1 << 5; else if (radius > 10) PlanetInfoPtr->Weather -= 1 << 5; - atmo = CalcFromBase (atmo, (atmo >> 1) + 1); + atmo = CalcHalfBaseVariance (atmo); } } @@ -194,7 +195,7 @@ bonus = COLD_BONUS; bonus <<= HINIBBLE (SysInfoPtr->PlanetInfo.PlanDataPtr->AtmoAndDensity); - bonus = CalcFromBase (bonus, (bonus >> 1) + 1); + bonus = CalcHalfBaseVariance (bonus); } return (centigrade + bonus); @@ -204,11 +205,11 @@ CalcRotation (PLANET_INFO *PlanetInfoPtr) { if (PLANSIZE (PlanetInfoPtr->PlanDataPtr->Type) == GAS_GIANT) - return ((COUNT)CalcFromBase (80, 80)); - else if (((BYTE)TFB_Random () % 10) == 0) - return ((COUNT)CalcFromBase ((UWORD)50 * 240, (UWORD)200 * 240)); + return CalcFromBase (80, 80); + else if (LOBYTE (RandomContext_Random (SysGenRNG)) % 10 == 0) + return CalcFromBase (50 * 240, 200 * 240); else - return ((COUNT)CalcFromBase (150, 150)); + return CalcFromBase (150, 150); } static SIZE @@ -223,23 +224,138 @@ i = NUM_TOSSES; do /* Using added Randomom values to give bell curve */ { - tilt += (UWORD)TFB_Random () % ((TILT_RANGE / NUM_TOSSES) + 1); + tilt += LOWORD (RandomContext_Random (SysGenRNG)) + % ((TILT_RANGE / NUM_TOSSES) + 1); } while (--i); return (tilt); } -// NB. Returns the RNG to the state it found it in. -DWORD +UWORD +CalcGravity (const PLANET_INFO *PlanetInfoPtr) +{ + return (DWORD)PlanetInfoPtr->PlanetDensity * PlanetInfoPtr->PlanetRadius + / 100; +} + +static UWORD +CalcTectonics (UWORD base, UWORD temp) +{ + UWORD tect = CalcFromBase (base, 3 << 5); +#ifdef OLD + if (temp >= HIGH_TEMP) + tect += HIGH_TEMP_BONUS; + else if (temp >= MED_TEMP) + tect += MED_TEMP_BONUS; + else if (temp >= LOW_TEMP) + tect += LOW_TEMP_BONUS; +#else /* !OLD */ + (void) temp; /* silence compiler whining */ +#endif /* OLD */ + return tect; +} + +// This code moved from planets/surface.c:CalcLifeForms() +static int +CalcLifeChance (const PLANET_INFO *PlanetInfoPtr) +{ + SIZE life_var = 0; + + if (PLANSIZE (PlanetInfoPtr->PlanDataPtr->Type) == GAS_GIANT) + return -1; + + if (PlanetInfoPtr->SurfaceTemperature < -151) + life_var -= 300; + else if (PlanetInfoPtr->SurfaceTemperature < -51) + life_var -= 100; + else if (PlanetInfoPtr->SurfaceTemperature < 0) + life_var += 100; + else if (PlanetInfoPtr->SurfaceTemperature < 50) + life_var += 300; + else if (PlanetInfoPtr->SurfaceTemperature < 150) + life_var += 50; + else if (PlanetInfoPtr->SurfaceTemperature < 250) + life_var -= 100; + else if (PlanetInfoPtr->SurfaceTemperature < 500) + life_var -= 400; + else + life_var -= 800; + + if (PlanetInfoPtr->AtmoDensity == 0) + life_var -= 1000; + else if (PlanetInfoPtr->AtmoDensity < 15) + life_var += 100; + else if (PlanetInfoPtr->AtmoDensity < 30) + life_var += 200; + else if (PlanetInfoPtr->AtmoDensity < 100) + life_var += 300; + else if (PlanetInfoPtr->AtmoDensity < 1000) + life_var += 150; + else if (PlanetInfoPtr->AtmoDensity < 2500) + ; + else + life_var -= 100; + +#ifndef NOTYET + life_var += 200 + 80 + 80; +#else /* NOTYET */ + if (PlanetInfoPtr->SurfaceGravity < 10) + ; + else if (PlanetInfoPtr->SurfaceGravity < 35) + life_var += 50; + else if (PlanetInfoPtr->SurfaceGravity < 75) + life_var += 100; + else if (PlanetInfoPtr->SurfaceGravity < 150) + life_var += 200; + else if (PlanetInfoPtr->SurfaceGravity < 400) + life_var += 50; + else if (PlanetInfoPtr->SurfaceGravity < 800) + ; + else + life_var -= 100; + + if (PlanetInfoPtr->Tectonics < 1) + life_var += 80; + else if (PlanetInfoPtr->Tectonics < 2) + life_var += 70; + else if (PlanetInfoPtr->Tectonics < 3) + life_var += 60; + else if (PlanetInfoPtr->Tectonics < 4) + life_var += 50; + else if (PlanetInfoPtr->Tectonics < 5) + life_var += 25; + else if (PlanetInfoPtr->Tectonics < 6) + ; + else + life_var -= 100; + + if (PlanetInfoPtr->Weather < 1) + life_var += 80; + else if (PlanetInfoPtr->Weather < 2) + life_var += 70; + else if (PlanetInfoPtr->Weather < 3) + life_var += 60; + else if (PlanetInfoPtr->Weather < 4) + life_var += 50; + else if (PlanetInfoPtr->Weather < 5) + life_var += 25; + else if (PlanetInfoPtr->Weather < 6) + ; + else + life_var -= 100; +#endif /* NOTYET */ + + return life_var; +} + +// Sets the SysGenRNG to the required state first. +void DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr, PLANET_DESC *pPlanetDesc) { - DWORD old_seed; + assert (pPlanetDesc->data_index != HIERARCHY_STARBASE); - if (pPlanetDesc->data_index == HIERARCHY_STARBASE) - return (0); + RandomContext_SeedRandom (SysGenRNG, pPlanetDesc->rand_seed); - old_seed = TFB_SeedRandom (pPlanetDesc->rand_seed); - CalcSysInfo (SysInfoPtr); #ifdef DEBUG_PLANET_CALC @@ -303,18 +419,18 @@ } SysInfoPtr->PlanetInfo.PlanetDensity += (SysInfoPtr->PlanetInfo.PlanetDensity / 20) - - ((COUNT)TFB_Random () + - (LOWORD (RandomContext_Random (SysGenRNG)) % (SysInfoPtr->PlanetInfo.PlanetDensity / 10)); switch (PLANSIZE (SysInfoPtr->PlanetInfo.PlanDataPtr->Type)) { case SMALL_ROCKY_WORLD: #define SMALL_RADIUS 25 - SysInfoPtr->PlanetInfo.PlanetRadius = CalcRadius (SMALL_RADIUS); + SysInfoPtr->PlanetInfo.PlanetRadius = CalcHalfBaseVariance (SMALL_RADIUS); break; case LARGE_ROCKY_WORLD: #define LARGE_RADIUS 75 - SysInfoPtr->PlanetInfo.PlanetRadius = CalcRadius (LARGE_RADIUS); + SysInfoPtr->PlanetInfo.PlanetRadius = CalcHalfBaseVariance (LARGE_RADIUS); break; case GAS_GIANT: #define MIN_GAS_RADIUS 300 @@ -325,9 +441,7 @@ } SysInfoPtr->PlanetInfo.RotationPeriod = CalcRotation (&SysInfoPtr->PlanetInfo); - SysInfoPtr->PlanetInfo.SurfaceGravity = - CalcGravity (SysInfoPtr->PlanetInfo.PlanetDensity, - SysInfoPtr->PlanetInfo.PlanetRadius); + SysInfoPtr->PlanetInfo.SurfaceGravity = CalcGravity (&SysInfoPtr->PlanetInfo); SysInfoPtr->PlanetInfo.AxialTilt = CalcTilt (); if ((SysInfoPtr->PlanetInfo.Tectonics = CalcTectonics (SysInfoPtr->PlanetInfo.PlanDataPtr->BaseTectonics, @@ -341,6 +455,8 @@ SysInfoPtr->PlanetInfo.Tectonics >>= 5; SysInfoPtr->PlanetInfo.Weather >>= 5; + SysInfoPtr->PlanetInfo.LifeChance = CalcLifeChance (&SysInfoPtr->PlanetInfo); + #ifdef DEBUG_PLANET_CALC radius = (SIZE)((DWORD)UNSCALE_RADIUS (radius) * 100 / UNSCALE_RADIUS (EARTH_RADIUS)); log_add (log_Debug, "\tOrbital Distance : %d.%02d AU", radius / 100, radius % 100); @@ -404,7 +520,5 @@ } #endif /* DEBUG_PLANET_CALC */ } - - return (TFB_SeedRandom (old_seed)); } Modified: trunk/sc2/src/uqm/planets/devices.c =================================================================== --- trunk/sc2/src/uqm/planets/devices.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/devices.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -18,6 +18,8 @@ #include "../build.h" #include "../colors.h" +#include "../gendef.h" +#include "../starmap.h" #include "../encount.h" #include "../gamestr.h" #include "../controls.h" Modified: trunk/sc2/src/uqm/planets/generate/genburv.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genburv.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genburv.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -85,7 +85,7 @@ solarSys->MoonDesc[0].data_index = SELENIC_WORLD; solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + (MAX_MOONS - 1) * MOON_DELTA; - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); solarSys->MoonDesc[0].location.x = COSINE (angle, solarSys->MoonDesc[0].radius); @@ -98,18 +98,17 @@ static bool GenerateBurvixese_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { - COUNT i; DWORD rand_val; - rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world); + DoPlanetaryAnalysis (&solarSys->SysInfo, world); + rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; - i = (COUNT)~0; - rand_val = GenerateLifeForms (&solarSys->SysInfo, &i); + GenerateLifeForms (&solarSys->SysInfo, GENERATE_ALL); + rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - i = (COUNT)~0; - GenerateMineralDeposits (&solarSys->SysInfo, &i); + GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL); solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; Modified: trunk/sc2/src/uqm/planets/generate/genchmmr.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genchmmr.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genchmmr.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -77,7 +77,7 @@ solarSys->MoonDesc[0].data_index = HIERARCHY_STARBASE; solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS; - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); solarSys->MoonDesc[0].location.x = COSINE (angle, solarSys->MoonDesc[0].radius); Modified: trunk/sc2/src/uqm/planets/generate/gendefault.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gendefault.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/gendefault.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -126,7 +126,6 @@ bool GenerateDefault_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { - COUNT i; DWORD rand_val; SYSTEM_INFO *sysInfo; @@ -146,15 +145,15 @@ sysInfo = &solarSys->SysInfo; - rand_val = DoPlanetaryAnalysis (sysInfo, world); + DoPlanetaryAnalysis (sysInfo, world); + rand_val = RandomContext_GetSeed (SysGenRNG); sysInfo->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; - i = (COUNT)~0; - rand_val = GenerateLifeForms (sysInfo, &i); + GenerateLifeForms (sysInfo, GENERATE_ALL); + rand_val = RandomContext_GetSeed (SysGenRNG); sysInfo->PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - i = (COUNT)~0; - GenerateMineralDeposits (sysInfo, &i); + GenerateMineralDeposits (sysInfo, GENERATE_ALL); sysInfo->PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; LoadPlanet (NULL); @@ -166,9 +165,8 @@ GenerateDefault_generateMinerals (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode) { - GenerateMineralDeposits (&solarSys->SysInfo, &whichNode); + return GenerateMineralDeposits (&solarSys->SysInfo, whichNode); (void) world; - return whichNode; } bool @@ -209,9 +207,8 @@ GenerateDefault_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world, COUNT whichNode) { - GenerateLifeForms (&solarSys->SysInfo, &whichNode); + return GenerateLifeForms (&solarSys->SysInfo, whichNode); (void) world; - return whichNode; } bool @@ -229,17 +226,15 @@ GenerateDefault_generateArtifact (SOLARSYS_STATE *solarSys, COUNT whichNode) { // Generate an energy node at a random location - GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, 1, 0, &whichNode); - return whichNode; + return GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, 1, 0, whichNode); } COUNT GenerateDefault_generateRuins (SOLARSYS_STATE *solarSys, COUNT whichNode) { // Generate a standard spread of city ruins of a destroyed civilization - GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, NUM_RACE_RUINS, - 0, &whichNode); - return whichNode; + return GenerateRandomNodes (&solarSys->SysInfo, ENERGY_SCAN, NUM_RACE_RUINS, + 0, whichNode); } static inline void @@ -309,7 +304,7 @@ BYTE num_moons; BYTE type; - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); byte_val = LOBYTE (rand_val); num_moons = 0; Modified: trunk/sc2/src/uqm/planets/generate/genmel.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genmel.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genmel.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -18,7 +18,8 @@ #include "genall.h" #include "../../build.h" -#include "../../encount.h" +#include "../../gendef.h" +#include "../../starmap.h" #include "../../globdata.h" #include "../../state.h" #include "libs/log.h" Modified: trunk/sc2/src/uqm/planets/generate/genmyc.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genmyc.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genmyc.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -22,7 +22,8 @@ #include "../scan.h" #include "../../build.h" #include "../../comm.h" -#include "../../encount.h" +#include "../../gendef.h" +#include "../../starmap.h" #include "../../globdata.h" #include "../../ipdisp.h" #include "../../nameref.h" Modified: trunk/sc2/src/uqm/planets/generate/genorz.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genorz.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genorz.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -21,7 +21,8 @@ #include "../planets.h" #include "../../build.h" #include "../../comm.h" -#include "../../encount.h" +#include "../../gendef.h" +#include "../../starmap.h" #include "../../globdata.h" #include "../../ipdisp.h" #include "../../nameref.h" Modified: trunk/sc2/src/uqm/planets/generate/genpet.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genpet.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genpet.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -21,6 +21,7 @@ #include "../../build.h" #include "../../comm.h" #include "../../encount.h" +#include "../../starmap.h" #include "../../globdata.h" #include "../../ipdisp.h" #include "../../nameref.h" Modified: trunk/sc2/src/uqm/planets/generate/genrain.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genrain.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genrain.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -18,7 +18,8 @@ #include "genall.h" #include "../planets.h" -#include "../../encount.h" +#include "../../gendef.h" +#include "../../starmap.h" #include "../../globdata.h" #include "libs/mathlib.h" Modified: trunk/sc2/src/uqm/planets/generate/gensam.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gensam.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/gensam.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -150,7 +150,7 @@ solarSys->MoonDesc[0].data_index = SA_MATRA; solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + (2 * MOON_DELTA); - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); solarSys->MoonDesc[0].location.x = COSINE (angle, solarSys->MoonDesc[0].radius); Modified: trunk/sc2/src/uqm/planets/generate/gensol.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/gensol.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/gensol.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -108,7 +108,7 @@ COUNT planetI; #define SOL_SEED 334241042L - TFB_SeedRandom (SOL_SEED); + RandomContext_SeedRandom (SysGenRNG, SOL_SEED); solarSys->SunDesc[0].NumPlanets = 9; for (planetI = 0; planetI < 9; ++planetI) @@ -118,7 +118,8 @@ UWORD word_val; PLANET_DESC *pCurDesc = &solarSys->PlanetDesc[planetI]; - pCurDesc->rand_seed = rand_val = TFB_Random (); + pCurDesc->rand_seed = RandomContext_Random (SysGenRNG); + rand_val = pCurDesc->rand_seed; word_val = LOWORD (rand_val); angle = NORMALIZE_ANGLE ((COUNT)HIBYTE (word_val)); @@ -208,7 +209,7 @@ solarSys->MoonDesc[1].data_index = SELENIC_WORLD; solarSys->MoonDesc[1].radius = MIN_MOON_RADIUS + (MAX_MOONS - 1) * MOON_DELTA; - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); solarSys->MoonDesc[1].location.x = COSINE (angle, solarSys->MoonDesc[1].radius); @@ -269,15 +270,12 @@ return true; } - rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world); - if (rand_val) - { - COUNT i; + DoPlanetaryAnalysis (&solarSys->SysInfo, world); + rand_val = RandomContext_GetSeed (SysGenRNG); - solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - i = (COUNT)~0; - rand_val = GenerateMineralDeposits (&solarSys->SysInfo, &i); - } + solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; + GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL); + rand_val = RandomContext_GetSeed (SysGenRNG); planetNr = planetIndex (solarSys, world); if (worldIsPlanet (solarSys, world)) @@ -405,8 +403,7 @@ } solarSys->SysInfo.PlanetInfo.SurfaceGravity = - CalcGravity (solarSys->SysInfo.PlanetInfo.PlanetDensity, - solarSys->SysInfo.PlanetInfo.PlanetRadius); + CalcGravity (&solarSys->SysInfo.PlanetInfo); LoadPlanet (planetNr == 2 ? CaptureDrawable (LoadGraphic (EARTH_MASK_ANIM)) : NULL); } @@ -421,6 +418,10 @@ switch (planetNr) { case 2: /* moons of EARTH */ + // NOTE: Even though we save the seed here, it is irrelevant. + // The seed will be used to randomly place the tractors, but + // since they are mobile, they will be moved to different + // locations not governed by this seed. solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; @@ -505,8 +506,7 @@ } solarSys->SysInfo.PlanetInfo.SurfaceGravity = - CalcGravity (solarSys->SysInfo.PlanetInfo.PlanetDensity, - solarSys->SysInfo.PlanetInfo.PlanetRadius); + CalcGravity (&solarSys->SysInfo.PlanetInfo); LoadPlanet (NULL); } @@ -601,9 +601,8 @@ if (matchWorld (solarSys, world, 2, 1)) { /* Earth Moon */ - GenerateRandomNodes (&solarSys->SysInfo, BIOLOGICAL_SCAN, 10, - NUM_CREATURE_TYPES + 1, &whichNode); - return whichNode; + return GenerateRandomNodes (&solarSys->SysInfo, BIOLOGICAL_SCAN, 10, + NUM_CREATURE_TYPES + 1, whichNode); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genspa.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genspa.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genspa.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -102,7 +102,7 @@ solarSys->MoonDesc[0].data_index = PELLUCID_WORLD; solarSys->MoonDesc[0].radius = MIN_MOON_RADIUS + MOON_DELTA; - angle = NORMALIZE_ANGLE (LOWORD (TFB_Random ())); + angle = NORMALIZE_ANGLE (LOWORD (RandomContext_Random (SysGenRNG))); solarSys->MoonDesc[0].location.x = COSINE (angle, solarSys->MoonDesc[0].radius); solarSys->MoonDesc[0].location.y = @@ -116,7 +116,6 @@ GenerateSpathi_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) { DWORD rand_val; - COUNT i; if (matchWorld (solarSys, world, 0, 0)) { @@ -144,15 +143,16 @@ } return true; } - rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world); + + DoPlanetaryAnalysis (&solarSys->SysInfo, world); + rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; - i = (COUNT)~0; - rand_val = GenerateLifeForms (&solarSys->SysInfo, &i); + GenerateLifeForms (&solarSys->SysInfo, GENERATE_ALL); + rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - i = (COUNT)~0; - GenerateMineralDeposits (&solarSys->SysInfo, &i); + GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL); solarSys->SysInfo.PlanetInfo.ScanSeed[ENERGY_SCAN] = rand_val; @@ -181,18 +181,18 @@ else if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { /* visiting Spathiwa */ - rand_val = DoPlanetaryAnalysis (&solarSys->SysInfo, world); + DoPlanetaryAnalysis (&solarSys->SysInfo, world); + rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[MINERAL_SCAN] = rand_val; - i = (COUNT)~0; - rand_val = GenerateMineralDeposits (&solarSys->SysInfo, &i); + GenerateMineralDeposits (&solarSys->SysInfo, GENERATE_ALL); + rand_val = RandomContext_GetSeed (SysGenRNG); solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN] = rand_val; solarSys->SysInfo.PlanetInfo.PlanetRadius = 120; solarSys->SysInfo.PlanetInfo.SurfaceGravity = - CalcGravity (solarSys->SysInfo.PlanetInfo.PlanetDensity, - solarSys->SysInfo.PlanetInfo.PlanetRadius); + CalcGravity (&solarSys->SysInfo.PlanetInfo); solarSys->SysInfo.PlanetInfo.Weather = 0; solarSys->SysInfo.PlanetInfo.Tectonics = 0; solarSys->SysInfo.PlanetInfo.SurfaceTemperature = 31; @@ -253,9 +253,8 @@ if (matchWorld (solarSys, world, 0, MATCH_PLANET)) { #define NUM_EVIL_ONES 32 - GenerateRandomNodes (&solarSys->SysInfo, BIOLOGICAL_SCAN, NUM_EVIL_ONES, - NUM_CREATURE_TYPES, &whichNode); - return whichNode; + return GenerateRandomNodes (&solarSys->SysInfo, BIOLOGICAL_SCAN, NUM_EVIL_ONES, + NUM_CREATURE_TYPES, whichNode); } return 0; Modified: trunk/sc2/src/uqm/planets/generate/genthrad.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genthrad.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genthrad.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -21,7 +21,8 @@ #include "../planets.h" #include "../../build.h" #include "../../comm.h" -#include "../../encount.h" +#include "../../gendef.h" +#include "../../starmap.h" #include "../../globdata.h" #include "../../ipdisp.h" #include "../../nameref.h" Modified: trunk/sc2/src/uqm/planets/generate/genutw.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genutw.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genutw.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -21,7 +21,8 @@ #include "../planets.h" #include "../../build.h" #include "../../comm.h" -#include "../../encount.h" +#include "../../gendef.h" +#include "../../starmap.h" #include "../../globdata.h" #include "../../ipdisp.h" #include "../../nameref.h" Modified: trunk/sc2/src/uqm/planets/generate/genvux.c =================================================================== --- trunk/sc2/src/uqm/planets/generate/genvux.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/generate/genvux.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -22,7 +22,8 @@ #include "../planets.h" #include "../../build.h" #include "../../comm.h" -#include "../../encount.h" +#include "../../gendef.h" +#include "../../starmap.h" #include "../../globdata.h" #include "../../ipdisp.h" #include "../../nameref.h" @@ -276,9 +277,8 @@ && matchWorld (solarSys, world, 0, MATCH_PLANET)) { COUNT i; - DWORD old_rand; - old_rand = TFB_SeedRandom ( + RandomContext_SeedRandom (SysGenRNG, solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); for (i = 0; i <= whichNode && i < 12; ++i) @@ -292,8 +292,6 @@ solarSys->SysInfo.PlanetInfo.CurType = 18; } - TFB_SeedRandom (old_rand); - return 12; // only matters when count is requested } @@ -301,9 +299,8 @@ && matchWorld (solarSys, world, 0, MATCH_PLANET)) { COUNT i; - DWORD old_rand; - old_rand = TFB_SeedRandom ( + RandomContext_SeedRandom (SysGenRNG, solarSys->SysInfo.PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); for (i = 0; i <= whichNode && i < 11; ++i) @@ -319,8 +316,6 @@ solarSys->SysInfo.PlanetInfo.CurType = 8; } - TFB_SeedRandom (old_rand); - return 11; // only matters when count is requested } Modified: trunk/sc2/src/uqm/planets/gentopo.c =================================================================== --- trunk/sc2/src/uqm/planets/gentopo.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/gentopo.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -43,9 +43,10 @@ DWORD rand_val; SBYTE *lpDst; - depth_delta = ((((SIZE)TFB_Random () & 1) << 1) - 1) * depth_delta; + if ((RandomContext_Random (SysGenRNG) & 1) == 0) + depth_delta = -depth_delta; - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); w1 = LOWORD (rand_val); w2 = HIWORD (rand_val); Modified: trunk/sc2/src/uqm/planets/lander.c =================================================================== --- trunk/sc2/src/uqm/planets/lander.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/lander.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -23,8 +23,6 @@ #include "../cons_res.h" #include "../controls.h" #include "../colors.h" -// XXX: for CurStarDescPtr and XXX_DEFINED -#include "../encount.h" #include "../process.h" #include "../units.h" #include "../gamestr.h" Modified: trunk/sc2/src/uqm/planets/orbits.c =================================================================== --- trunk/sc2/src/uqm/planets/orbits.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/orbits.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -17,8 +17,7 @@ */ #include "planets.h" -// XXX: for CurStarDescPtr -#include "../encount.h" +#include "../starmap.h" #include "libs/compiler.h" #include "libs/mathlib.h" #include "libs/log.h" @@ -499,10 +498,15 @@ if (NumPlanets == (BYTE)~0) { -#define MAX_GENERATED_PLANETS 10 - while ((NumPlanets = (BYTE)(LOWORD (TFB_Random()) - % MAX_GENERATED_PLANETS)) == 0) - ; +#define MAX_GENERATED_PLANETS 9 + // XXX: This is pretty funny. Instead of calling RNG once, like so: + // 1 + Random % MAX_GENERATED_PLANETS + // we spin in a loop until the result > 0. + // Note that this behavior must be kept to preserve the universe. + do + NumPlanets = LOWORD (RandomContext_Random (SysGenRNG)) + % (MAX_GENERATED_PLANETS + 1); + while (NumPlanets == 0); system->SunDesc[0].NumPlanets = NumPlanets; } @@ -528,7 +532,7 @@ do { - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); if (TypesDefined) rand_val = 0; else @@ -564,7 +568,7 @@ else min_radius = Suns[StarSize].MinGasGDist; RelocatePlanet: - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); if (GeneratingMoons) { pPD->radius = MIN_MOON_RADIUS @@ -592,7 +596,7 @@ } } - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); pPD->location.x = COSINE (angle, pPD->radius); pPD->location.y = SINE (angle, pPD->radius); Modified: trunk/sc2/src/uqm/planets/plandata.h =================================================================== --- trunk/sc2/src/uqm/planets/plandata.h 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/plandata.h 2011-09-09 01:59:12 UTC (rev 3694) @@ -313,8 +313,7 @@ SUPER_DENSITY }; -#define CalcGravity(d,r) (UWORD)((DWORD)(d) * (r) / 100) -#define CalcFromBase(b,v) ((UWORD)(b) + ((UWORD)TFB_Random () % (v))) +extern UWORD CalcGravity (const PLANET_INFO*); #define EARTH_ATMOSPHERE 50 Modified: trunk/sc2/src/uqm/planets/planets.h =================================================================== --- trunk/sc2/src/uqm/planets/planets.h 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/planets.h 2011-09-09 01:59:12 UTC (rev 3694) @@ -19,6 +19,8 @@ #ifndef _PLANETS_H #define _PLANETS_H +#include "libs/mathlib.h" + #define END_INTERPLANETARY START_INTERPLANETARY enum PlanetScanTypes @@ -233,6 +235,9 @@ extern MUSIC_REF SpaceMusic; extern CONTEXT PlanetContext; +// Random context used for all solar system, planets and surfaces generation +extern RandomContext *SysGenRNG; + bool playerInSolarSystem (void); bool playerInPlanetOrbit (void); bool playerInInnerSystem (void); @@ -244,6 +249,8 @@ bool matchWorld (const SOLARSYS_STATE *solarSys, const PLANET_DESC *world, BYTE planetI, BYTE moonI); +DWORD GetRandomSeedForStar (const STAR_DESC *star); + POINT locationToDisplay (POINT pt, SIZE scaleRadius); POINT displayToLocation (POINT pt, SIZE scaleRadius); POINT planetOuterLocation (COUNT planetI); Modified: trunk/sc2/src/uqm/planets/plangen.c =================================================================== --- trunk/sc2/src/uqm/planets/plangen.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/plangen.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -842,7 +842,7 @@ { // Use up the random value byte by byte if ((i & 3) == 0) - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); else rand_val >>= 8; @@ -1066,7 +1066,7 @@ intersect = FALSE; - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); loword = LOWORD (rand_val); hiword = HIWORD (rand_val); switch (HIBYTE (hiword) & 31) @@ -1094,7 +1094,7 @@ if (pstorm_r->extent.height <= 4) pstorm_r->extent.height += 4; - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); loword = LOWORD (rand_val); hiword = HIWORD (rand_val); @@ -1183,7 +1183,7 @@ band_error = num_bands >> 1; lpDst = DepthArray; - band_delta = ((LOWORD (TFB_Random ()) + band_delta = ((LOWORD (RandomContext_Random (SysGenRNG)) & (NUM_BAND_COLORS - 1)) << RANGE_SHIFT) + (1 << (RANGE_SHIFT - 1)); last_y = next_y = 0; @@ -1191,7 +1191,7 @@ { COORD cur_y; - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); loword = LOWORD (rand_val); hiword = HIWORD (rand_val); @@ -1232,7 +1232,7 @@ & (((1 << RANGE_SHIFT) * NUM_BAND_COLORS) - 1); } - MakeStorms (4 + (TFB_Random () & 3) + 1, DepthArray); + MakeStorms (4 + (RandomContext_Random (SysGenRNG) & 3) + 1, DepthArray); DitherMap (DepthArray); } @@ -1718,11 +1718,11 @@ } } +// Sets the SysGenRNG to the required state first. void GeneratePlanetSurface (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame) { RECT r; - DWORD old_seed; const PlanetFrame *PlanDataPtr; PLANET_INFO *PlanetInfo = &pSolarSysState->SysInfo.PlanetInfo; COUNT i, y; @@ -1732,7 +1732,7 @@ PLANET_ORBIT *Orbit = &pSolarSysState->Orbit; BOOLEAN shielded = (pPlanetDesc->data_index & PLANET_SHIELDED) != 0; - old_seed = TFB_SeedRandom (pPlanetDesc->rand_seed); + RandomContext_SeedRandom (SysGenRNG, pPlanetDesc->rand_seed); TopoContext = CreateContext ("Plangen.TopoContext"); LockMutex (GraphicsLock); @@ -1818,7 +1818,7 @@ RECT crater_r; UWORD loword; - loword = LOWORD (TFB_Random ()); + loword = LOWORD (RandomContext_Random (SysGenRNG)); switch (HIBYTE (loword) & 31) { case 0: @@ -1841,7 +1841,7 @@ break; } - loword = LOWORD (TFB_Random ()); + loword = LOWORD (RandomContext_Random (SysGenRNG)); crater_r.extent.height = crater_r.extent.width; crater_r.corner.x = HIBYTE (loword) % (MAP_WIDTH - crater_r.extent.width); @@ -1952,7 +1952,5 @@ SetContext (OldContext); UnlockMutex (GraphicsLock); DestroyContext (TopoContext); - - TFB_SeedRandom (old_seed); } Modified: trunk/sc2/src/uqm/planets/pstarmap.c =================================================================== --- trunk/sc2/src/uqm/planets/pstarmap.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/pstarmap.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -20,8 +20,7 @@ #include "../colors.h" #include "../controls.h" #include "../menustat.h" -// XXX: for stuff that does not belong there -#include "../encount.h" +#include "../starmap.h" #include "../races.h" #include "../gameopt.h" #include "../gamestr.h" Modified: trunk/sc2/src/uqm/planets/scan.c =================================================================== --- trunk/sc2/src/uqm/planets/scan.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/scan.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -1300,6 +1300,8 @@ creatureType = system->SysInfo.PlanetInfo.CurType; + // NOTE: TFB_Random() calls here are NOT part of the deterministic planet + // generation PRNG flow. if (CreatureData[creatureType].Attributes & SPEED_MASK) { // Place moving creatures at a random location. Modified: trunk/sc2/src/uqm/planets/solarsys.c =================================================================== --- trunk/sc2/src/uqm/planets/solarsys.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/solarsys.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -22,7 +22,7 @@ #include "../controls.h" #include "../menustat.h" // for DrawMenuStateStrings() -#include "../encount.h" +#include "../starmap.h" #include "../races.h" #include "../gamestr.h" #include "../gendef.h" @@ -95,6 +95,7 @@ static RECT scaleRect; // system zooms in when the flagship enters this rect +RandomContext *SysGenRNG; #define DISPLAY_TO_LOC (DISPLAY_FACTOR >> 1) @@ -211,15 +212,15 @@ return pSolarSysState->pBaseDesc != pSolarSysState->PlanetDesc; } +// Sets the SysGenRNG to the required state first. static void GenerateMoons (SOLARSYS_STATE *system, PLANET_DESC *planet) { COUNT i; COUNT facing; PLANET_DESC *pMoonDesc; - DWORD old_seed; - old_seed = TFB_SeedRandom (planet->rand_seed); + RandomContext_SeedRandom (SysGenRNG, planet->rand_seed); (*system->genFuncs->generateName) (system, planet); (*system->genFuncs->generateMoons) (system, planet); @@ -235,8 +236,6 @@ pMoonDesc->temp_color = planet->temp_color; } - - TFB_SeedRandom (old_seed); } void @@ -256,6 +255,9 @@ SpaceJunkFrame = 0; DestroyMusic (SpaceMusic); SpaceMusic = 0; + + RandomContext_Delete (SysGenRNG); + SysGenRNG = NULL; } void @@ -275,6 +277,11 @@ SpaceMusic = LoadMusic (IP_MUSIC); } + + if (!SysGenRNG) + { + SysGenRNG = RandomContext_New (); + } } @@ -350,11 +357,10 @@ } } -static DWORD -seedRandomForSolarSys (void) +DWORD +GetRandomSeedForStar (const STAR_DESC *star) { - return TFB_SeedRandom (MAKE_DWORD (CurStarDescPtr->star_pt.x, - CurStarDescPtr->star_pt.y)); + return MAKE_DWORD (star->star_pt.x, star->star_pt.y); } // Returns an orbital PLANET_DESC when player is in orbit @@ -364,7 +370,6 @@ COUNT i; PLANET_DESC *orbital = NULL; PLANET_DESC *pCurDesc; - DWORD old_seed; #define NUM_TEMP_RANGES 5 static const Color temp_color_array[NUM_TEMP_RANGES] = { @@ -375,13 +380,13 @@ BUILD_COLOR (MAKE_RGB15_INIT (0x0F, 0x08, 0x00), 0x75), }; - old_seed = seedRandomForSolarSys (); + RandomContext_SeedRandom (SysGenRNG, GetRandomSeedForStar (CurStarDescPtr)); SunFrame = SetAbsFrameIndex (SunFrame, STAR_TYPE (CurStarDescPtr->Type)); pCurDesc = &pSolarSysState->SunDesc[0]; pCurDesc->pPrevDesc = 0; - pCurDesc->rand_seed = TFB_Random (); + pCurDesc->rand_seed = RandomContext_Random (SysGenRNG); pCurDesc->data_index = STAR_TYPE (CurStarDescPtr->Type); pCurDesc->location.x = 0; @@ -467,9 +472,6 @@ GLOBAL (ShipStamp.frame) = SetAbsFrameIndex (SISIPFrame, i - 1); } - // Restore RNG state: - TFB_SeedRandom (old_seed); - return orbital; } @@ -1656,7 +1658,6 @@ COUNT i, j; DWORD rand_val; STAMP s; - DWORD old_seed; CONTEXT oldContext; RECT clipRect; FRAME frame; @@ -1675,7 +1676,7 @@ ClearDrawable (); - old_seed = seedRandomForSolarSys (); + RandomContext_SeedRandom (SysGenRNG, GetRandomSeedForStar (CurStarDescPtr)); #define NUM_DIM_PIECES 8 s.frame = SpaceJunkFrame; @@ -1684,7 +1685,7 @@ #define NUM_DIM_DRAWN 5 for (j = 0; j < NUM_DIM_DRAWN; ++j) { - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); s.origin.x = LOWORD (rand_val) % SIS_SCREEN_WIDTH; s.origin.y = HIWORD (rand_val) % SIS_SCREEN_HEIGHT; @@ -1698,7 +1699,7 @@ #define NUM_BRT_DRAWN 30 for (j = 0; j < NUM_BRT_DRAWN; ++j) { - rand_val = TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); s.origin.x = LOWORD (rand_val) % SIS_SCREEN_WIDTH; s.origin.y = HIWORD (rand_val) % SIS_SCREEN_HEIGHT; @@ -1707,8 +1708,6 @@ s.frame = IncFrameIndex (s.frame); } - TFB_SeedRandom (old_seed); - SetContext (oldContext); return frame; Modified: trunk/sc2/src/uqm/planets/sundata.h =================================================================== --- trunk/sc2/src/uqm/planets/sundata.h 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/sundata.h 2011-09-09 01:59:12 UTC (rev 3694) @@ -42,13 +42,15 @@ PLANET_INFO PlanetInfo; } SYSTEM_INFO; + +#define GENERATE_ALL ((COUNT)~0) -extern DWORD GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr, - COUNT *pwhich_deposit); -extern DWORD GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT *pwhich_life); +extern COUNT GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr, + COUNT whichDeposit); +extern COUNT GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT whichLife); extern void GenerateRandomLocation (SYSTEM_INFO *); -extern DWORD GenerateRandomNodes (SYSTEM_INFO *, COUNT scan, COUNT numNodes, - COUNT type, COUNT *whichNode); +extern COUNT GenerateRandomNodes (SYSTEM_INFO *, COUNT scan, COUNT numNodes, + COUNT type, COUNT whichNode); #define DWARF_ELEMENT_DENSITY 1 #define GIANT_ELEMENT_DENSITY 3 @@ -56,11 +58,9 @@ #define MAX_ELEMENT_DENSITY ((MAX_ELEMENT_UNITS * SUPERGIANT_ELEMENT_DENSITY) << 1) -extern DWORD DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr, +extern void DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr, PLANET_DESC *pPlanetDesc); -extern SYSTEM_INFO CurSysInfo; - #if defined(__cplusplus) } #endif Modified: trunk/sc2/src/uqm/planets/surface.c =================================================================== --- trunk/sc2/src/uqm/planets/surface.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/planets/surface.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -41,16 +41,16 @@ { BYTE num_possible; - num_possible = (BYTE)((BYTE)TFB_Random () - % (DEPOSIT_QUANTITY (eptr->Density) + 1)); + num_possible = LOBYTE (RandomContext_Random (SysGenRNG)) + % (DEPOSIT_QUANTITY (eptr->Density) + 1); while (num_possible--) { #define MEDIUM_DEPOSIT_THRESHOLD 150 #define LARGE_DEPOSIT_THRESHOLD 225 - COUNT deposit_quality_fine, - deposit_quality_gross; + COUNT deposit_quality_fine; + COUNT deposit_quality_gross; - deposit_quality_fine = ((COUNT)TFB_Random () % 100) + deposit_quality_fine = (LOWORD (RandomContext_Random (SysGenRNG)) % 100) + ( DEPOSIT_QUALITY (eptr->Density) + SysInfoPtr->StarSize @@ -85,14 +85,16 @@ return (num_deposits); } -DWORD -GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr, COUNT *pwhich_deposit) +// Returns: +// for whichLife==~0 : the number of nodes generated +// for whichLife<32 : the index of the last node (no known usage exists) +// Sets the SysGenRNG to the required state first. +COUNT +GenerateMineralDeposits (SYSTEM_INFO *SysInfoPtr, COUNT whichDeposit) { - DWORD old_rand; - - old_rand = TFB_SeedRandom (SysInfoPtr->PlanetInfo.ScanSeed[MINERAL_SCAN]); - *pwhich_deposit = CalcMineralDeposits (SysInfoPtr, *pwhich_deposit); - return (TFB_SeedRandom (old_rand)); + RandomContext_SeedRandom (SysGenRNG, + SysInfoPtr->PlanetInfo.ScanSeed[MINERAL_SCAN]); + return CalcMineralDeposits (SysInfoPtr, whichDeposit); } static COUNT @@ -101,114 +103,28 @@ COUNT num_life_forms; num_life_forms = 0; - if (PLANSIZE (SysInfoPtr->PlanetInfo.PlanDataPtr->Type) == GAS_GIANT) - SysInfoPtr->PlanetInfo.LifeChance = -1; - else + if (PLANSIZE (SysInfoPtr->PlanetInfo.PlanDataPtr->Type) != GAS_GIANT) { #define MIN_LIFE_CHANCE 10 SIZE life_var; - life_var = 0; - - if (SysInfoPtr->PlanetInfo.SurfaceTemperature < -151) - life_var -= 300; - else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < -51) - life_var -= 100; - else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < 0) - life_var += 100; - else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < 50) - life_var += 300; - else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < 150) - life_var += 50; - else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < 250) - life_var -= 100; - else if (SysInfoPtr->PlanetInfo.SurfaceTemperature < 500) - life_var -= 400; - else - life_var -= 800; - - if (SysInfoPtr->PlanetInfo.AtmoDensity == 0) - life_var -= 1000; - else if (SysInfoPtr->PlanetInfo.AtmoDensity < 15) - life_var += 100; - else if (SysInfoPtr->PlanetInfo.AtmoDensity < 30) - life_var += 200; - else if (SysInfoPtr->PlanetInfo.AtmoDensity < 100) - life_var += 300; - else if (SysInfoPtr->PlanetInfo.AtmoDensity < 1000) - life_var += 150; - else if (SysInfoPtr->PlanetInfo.AtmoDensity < 2500) - ; - else - life_var -= 100; - -#ifndef NOTYET - life_var += 200 + 80 + 80; -#else /* NOTYET */ - if (SysInfoPtr->PlanetInfo.SurfaceGravity < 10) - ; - else if (SysInfoPtr->PlanetInfo.SurfaceGravity < 35) - life_var += 50; - else if (SysInfoPtr->PlanetInfo.SurfaceGravity < 75) - life_var += 100; - else if (SysInfoPtr->PlanetInfo.SurfaceGravity < 150) - life_var += 200; - else if (SysInfoPtr->PlanetInfo.SurfaceGravity < 400) - life_var += 50; - else if (SysInfoPtr->PlanetInfo.SurfaceGravity < 800) - ; - else - life_var -= 100; - - if (SysInfoPtr->PlanetInfo.Tectonics < 1) - life_var += 80; - else if (SysInfoPtr->PlanetInfo.Tectonics < 2) - life_var += 70; - else if (SysInfoPtr->PlanetInfo.Tectonics < 3) - life_var += 60; - else if (SysInfoPtr->PlanetInfo.Tectonics < 4) - life_var += 50; - else if (SysInfoPtr->PlanetInfo.Tectonics < 5) - life_var += 25; - else if (SysInfoPtr->PlanetInfo.Tectonics < 6) - ; - else - life_var -= 100; - - if (SysInfoPtr->PlanetInfo.Weather < 1) - life_var += 80; - else if (SysInfoPtr->PlanetInfo.Weather < 2) - life_var += 70; - else if (SysInfoPtr->PlanetInfo.Weather < 3) - life_var += 60; - else if (SysInfoPtr->PlanetInfo.Weather < 4) - life_var += 50; - else if (SysInfoPtr->PlanetInfo.Weather < 5) - life_var += 25; - else if (SysInfoPtr->PlanetInfo.Weather < 6) - ; - else - life_var -= 100; -#endif /* NOTYET */ - - SysInfoPtr->PlanetInfo.LifeChance = life_var; - - life_var = (COUNT)TFB_Random () & 1023; + life_var = RandomContext_Random (SysGenRNG) & 1023; if (life_var < SysInfoPtr->PlanetInfo.LifeChance || (SysInfoPtr->PlanetInfo.LifeChance < MIN_LIFE_CHANCE && life_var < MIN_LIFE_CHANCE)) { BYTE num_types; - num_types = (BYTE)(((BYTE)TFB_Random () % MAX_LIFE_VARIATION) + 1); + num_types = 1 + LOBYTE (RandomContext_Random (SysGenRNG)) + % MAX_LIFE_VARIATION; do { BYTE index, num_creatures; UWORD rand_val; - rand_val = (UWORD)TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); index = LOBYTE (rand_val) % NUM_CREATURE_TYPES; - num_creatures = (BYTE)((HIBYTE (rand_val) % 10) + 1); + num_creatures = 1 + HIBYTE (rand_val) % 10; do { GenerateRandomLocation (SysInfoPtr); @@ -233,15 +149,16 @@ return (num_life_forms); } -DWORD -GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT *pwhich_life) +// Returns: +// for whichLife==~0 : the number of lifeforms generated +// for whichLife<32 : the index of the last lifeform (no known usage exists) +// Sets the SysGenRNG to the required state first. +COUNT +GenerateLifeForms (SYSTEM_INFO *SysInfoPtr, COUNT whichLife) { - DWORD old_rand; - - old_rand = TFB_SeedRandom ( + RandomContext_SeedRandom (SysGenRNG, SysInfoPtr->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); - *pwhich_life = CalcLifeForms (SysInfoPtr, *pwhich_life); - return (TFB_SeedRandom (old_rand)); + return CalcLifeForms (SysInfoPtr, whichLife); } void @@ -249,21 +166,24 @@ { UWORD rand_val; - rand_val = (UWORD)TFB_Random (); + rand_val = RandomContext_Random (SysGenRNG); SysInfoPtr->PlanetInfo.CurPt.x = (LOBYTE (rand_val) % (MAP_WIDTH - (8 << 1))) + 8; SysInfoPtr->PlanetInfo.CurPt.y = (HIBYTE (rand_val) % (MAP_HEIGHT - (8 << 1))) + 8; } -DWORD +// Returns: +// for whichNode==~0 : the number of nodes generated +// for whichNode<32 : the index of the last node (no known usage exists) +// Sets the SysGenRNG to the required state first. +COUNT GenerateRandomNodes (SYSTEM_INFO *SysInfoPtr, COUNT scan, COUNT numNodes, - COUNT type, COUNT *whichNode) + COUNT type, COUNT whichNode) { - DWORD old_rand; COUNT i; - old_rand = TFB_SeedRandom (SysInfoPtr->PlanetInfo.ScanSeed[scan]); + RandomContext_SeedRandom (SysGenRNG, SysInfoPtr->PlanetInfo.ScanSeed[scan]); for (i = 0; i < numNodes; ++i) { @@ -273,11 +193,9 @@ // CurDensity is irrelevant for energy and bio nodes SysInfoPtr->PlanetInfo.CurDensity = 0; - if (i >= *whichNode) + if (i >= whichNode) break; } - *whichNode = i; // only matters when count is requested - - return (TFB_SeedRandom (old_rand)); + return i; } Modified: trunk/sc2/src/uqm/restart.c =================================================================== --- trunk/sc2/src/uqm/restart.c 2011-09-08 15:25:32 UTC (rev 3693) +++ trunk/sc2/src/uqm/restart.c 2011-09-09 01:59:12 UTC (rev 3694) @@ -21,8 +21,7 @@ #include "colors.h" #include "controls.h" #include "credits.h" -// XXX: for star_array[] -#include "encount.h" +#include "starmap.h" #include "fmv.h" #include "menustat.h" #include "gamestr.h" Modified: trunk/sc2/src/uqm/save.c ========================================================... [truncated message content] |
From: <av...@us...> - 2011-09-08 15:25:43
|
Revision: 3693 http://sc2.svn.sourceforge.net/sc2/?rev=3693&view=rev Author: avolkov Date: 2011-09-08 15:25:32 +0000 (Thu, 08 Sep 2011) Log Message: ----------- Eliminate the use of C++ keyword 'template'; bug #1131; from Scott A. Colcord Modified Paths: -------------- trunk/sc2/src/libs/graphics/sdl/opengl.c trunk/sc2/src/libs/graphics/sdl/pure.c trunk/sc2/src/libs/inplib.h trunk/sc2/src/libs/input/sdl/input.c trunk/sc2/src/uqm/setupmenu.c Modified: trunk/sc2/src/libs/graphics/sdl/opengl.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/opengl.c 2011-09-07 18:07:26 UTC (rev 3692) +++ trunk/sc2/src/libs/graphics/sdl/opengl.c 2011-09-08 15:25:32 UTC (rev 3693) @@ -70,12 +70,12 @@ static SDL_Surface * -Create_Screen (SDL_Surface *template, int w, int h) +Create_Screen (SDL_Surface *templat, int w, int h) { SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, - template->format->BitsPerPixel, - template->format->Rmask, template->format->Gmask, - template->format->Bmask, 0); + templat->format->BitsPerPixel, + templat->format->Rmask, templat->format->Gmask, + templat->format->Bmask, 0); if (newsurf == 0) { log_add (log_Error, "Couldn't create screen buffers: %s", SDL_GetError()); @@ -84,11 +84,11 @@ } static int -ReInit_Screen (SDL_Surface **screen, SDL_Surface *template, int w, int h) +ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h) { if (*screen) SDL_FreeSurface (*screen); - *screen = Create_Screen (template, w, h); + *screen = Create_Screen (templat, w, h); return *screen == 0 ? -1 : 0; } Modified: trunk/sc2/src/libs/graphics/sdl/pure.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/pure.c 2011-09-07 18:07:26 UTC (rev 3692) +++ trunk/sc2/src/libs/graphics/sdl/pure.c 2011-09-08 15:25:32 UTC (rev 3693) @@ -48,12 +48,12 @@ TFB_Pure_ColorLayer }; static SDL_Surface * -Create_Screen (SDL_Surface *template, int w, int h) +Create_Screen (SDL_Surface *templat, int w, int h) { SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, - template->format->BitsPerPixel, - template->format->Rmask, template->format->Gmask, - template->format->Bmask, 0); + templat->format->BitsPerPixel, + templat->format->Rmask, templat->format->Gmask, + templat->format->Bmask, 0); if (newsurf == 0) { log_add (log_Error, "Couldn't create screen buffers: %s", SDL_GetError()); @@ -62,11 +62,11 @@ } static int -ReInit_Screen (SDL_Surface **screen, SDL_Surface *template, int w, int h) +ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h) { if (*screen) SDL_FreeSurface (*screen); - *screen = Create_Screen (template, w, h); + *screen = Create_Screen (templat, w, h); return *screen == 0 ? -1 : 0; } Modified: trunk/sc2/src/libs/inplib.h =================================================================== --- trunk/sc2/src/libs/inplib.h 2011-09-07 18:07:26 UTC (rev 3692) +++ trunk/sc2/src/libs/inplib.h 2011-09-08 15:25:32 UTC (rev 3693) @@ -53,9 +53,9 @@ /* Interrogating the current key configuration */ -void InterrogateInputState (int template, int control, int index, char *buffer, int maxlen); -void RemoveInputState (int template, int control, int index); -void RebindInputState (int template, int control, int index); +void InterrogateInputState (int templat, int control, int index, char *buffer, int maxlen); +void RemoveInputState (int templat, int control, int index); +void RebindInputState (int templat, int control, int index); void SaveKeyConfiguration (uio_DirHandle *path, const char *fname); Modified: trunk/sc2/src/libs/input/sdl/input.c =================================================================== --- trunk/sc2/src/libs/input/sdl/input.c 2011-09-07 18:07:26 UTC (rev 3692) +++ trunk/sc2/src/libs/input/sdl/input.c 2011-09-08 15:25:32 UTC (rev 3693) @@ -420,11 +420,11 @@ } void -InterrogateInputState (int template, int control, int index, char *buffer, int maxlen) +InterrogateInputState (int templat, int control, int index, char *buffer, int maxlen) { - VCONTROL_GESTURE *g = CONTROL_PTR(template, control, index); + VCONTROL_GESTURE *g = CONTROL_PTR(templat, control, index); - if (template >= num_templ || control >= num_flight + if (templat >= num_templ || control >= num_flight || index >= MAX_FLIGHT_ALTERNATES) { log_add (log_Warning, "InterrogateInputState(): invalid control index"); @@ -457,13 +457,13 @@ } void -RemoveInputState (int template, int control, int index) +RemoveInputState (int templat, int control, int index) { - VCONTROL_GESTURE *g = CONTROL_PTR(template, control, index); + VCONTROL_GESTURE *g = CONTROL_PTR(templat, control, index); char keybuf[40]; keybuf[39] = '\0'; - if (template >= num_templ || control >= num_flight + if (templat >= num_templ || control >= num_flight || index >= MAX_FLIGHT_ALTERNATES) { log_add (log_Warning, "RemoveInputState(): invalid control index"); @@ -471,23 +471,23 @@ } VControl_RemoveGestureBinding (g, - (int *)(flight_vec + template * num_flight + control)); + (int *)(flight_vec + templat * num_flight + control)); g->type = VCONTROL_NONE; - snprintf (keybuf, 39, "keys.%d.%s.%d", template+1, flight_res_names[control], index+1); + snprintf (keybuf, 39, "keys.%d.%s.%d", templat+1, flight_res_names[control], index+1); res_Remove (keybuf); return; } void -RebindInputState (int template, int control, int index) +RebindInputState (int templat, int control, int index) { VCONTROL_GESTURE g; char keybuf[40], valbuf[40]; keybuf[39] = valbuf[39] = '\0'; - if (template >= num_templ || control >= num_flight + if (templat >= num_templ || control >= num_flight || index >= MAX_FLIGHT_ALTERNATES) { log_add (log_Warning, "RebindInputState(): invalid control index"); @@ -495,7 +495,7 @@ } /* Remove the old binding on this spot */ - RemoveInputState (template, control, index); + RemoveInputState (templat, control, index); /* Wait for the next interesting bit of user input */ VControl_ClearGesture (); @@ -506,9 +506,9 @@ /* And now, add the new binding. */ VControl_AddGestureBinding (&g, - (int *)(flight_vec + template * num_flight + control)); - *CONTROL_PTR(template, control, index) = g; - snprintf (keybuf, 39, "keys.%d.%s.%d", template+1, flight_res_names[control], index+1); + (int *)(flight_vec + templat * num_flight + control)); + *CONTROL_PTR(templat, control, index) = g; + snprintf (keybuf, 39, "keys.%d.%s.%d", templat+1, flight_res_names[control], index+1); VControl_DumpGesture (valbuf, 39, &g); res_PutString (keybuf, valbuf); } Modified: trunk/sc2/src/uqm/setupmenu.c =================================================================== --- trunk/sc2/src/uqm/setupmenu.c 2011-09-07 18:07:26 UTC (rev 3692) +++ trunk/sc2/src/uqm/setupmenu.c 2011-09-08 15:25:32 UTC (rev 3693) @@ -321,18 +321,18 @@ } static void -populate_editkeys (int template) +populate_editkeys (int templat) { int i, j; - strncpy (textentries[0].value, input_templates[template].name, textentries[0].maxlen); + strncpy (textentries[0].value, input_templates[templat].name, textentries[0].maxlen); textentries[0].value[textentries[0].maxlen-1] = 0; for (i = 0; i < NUM_KEYS; i++) { for (j = 0; j < 2; j++) { - InterrogateInputState (template, i, j, controlentries[i].controlname[j], WIDGET_CONTROLENTRY_WIDTH); + InterrogateInputState (templat, i, j, controlentries[i].controlname[j], WIDGET_CONTROLENTRY_WIDTH); } } } @@ -743,26 +743,26 @@ static void rebind_control (WIDGET_CONTROLENTRY *widget) { - int template = choices[20].selected; + int templat = choices[20].selected; int control = widget->controlindex; int index = widget->highlighted; FlushInput (); DrawLabelAsWindow (&labels[3], NULL); - RebindInputState (template, control, index); - populate_editkeys (template); + RebindInputState (templat, control, index); + populate_editkeys (templat); FlushInput (); } static void clear_control (WIDGET_CONTROLENTRY *widget) { - int template = choices[20].selected; + int templat = choices[20].selected; int control = widget->controlindex; int index = widget->highlighted; - RemoveInputState (template, control, index); - populate_editkeys (template); + RemoveInputState (templat, control, index); + populate_editkeys (templat); } static int This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-07 18:07:32
|
Revision: 3692 http://sc2.svn.sourceforge.net/sc2/?rev=3692&view=rev Author: avolkov Date: 2011-09-07 18:07:26 +0000 (Wed, 07 Sep 2011) Log Message: ----------- Fix prototype warning in libs/file Modified Paths: -------------- trunk/sc2/src/libs/file/dirs.c Modified: trunk/sc2/src/libs/file/dirs.c =================================================================== --- trunk/sc2/src/libs/file/dirs.c 2011-09-07 18:03:10 UTC (rev 3691) +++ trunk/sc2/src/libs/file/dirs.c 2011-09-07 18:07:26 UTC (rev 3692) @@ -656,7 +656,7 @@ // This code is only needed if we have a current working directory // per drive. // letter is 0 based: 0 = A, 1 = B, ... -bool +static bool driveLetterExists(int letter) { unsigned long drives; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-07 18:03:21
|
Revision: 3691 http://sc2.svn.sourceforge.net/sc2/?rev=3691&view=rev Author: avolkov Date: 2011-09-07 18:03:10 +0000 (Wed, 07 Sep 2011) Log Message: ----------- Fix strict warnings in screen scalers, bug #50; from Sze Howe Koh Modified Paths: -------------- trunk/sc2/src/libs/graphics/sdl/scalers.c Modified: trunk/sc2/src/libs/graphics/sdl/scalers.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/scalers.c 2011-09-07 06:17:23 UTC (rev 3690) +++ trunk/sc2/src/libs/graphics/sdl/scalers.c 2011-09-07 18:03:10 UTC (rev 3691) @@ -211,7 +211,7 @@ // add better platform techs to the top #ifdef MMX_ASM if ( (!force_platform && (SDL_HasSSE () || SDL_HasMMXExt ())) - || force_platform == SCALEPLAT_SSE) + || force_platform == PLATFORM_SSE) { log_add (log_Info, "Screen scalers are using SSE/MMX-Ext/MMX code"); Scale_Platform = SCALEPLAT_SSE; @@ -220,7 +220,7 @@ } else if ( (!force_platform && SDL_HasAltiVec ()) - || force_platform == SCALEPLAT_ALTIVEC) + || force_platform == PLATFORM_ALTIVEC) { log_add (log_Info, "Screen scalers would use AltiVec code " "if someone actually wrote it"); @@ -228,7 +228,7 @@ } else if ( (!force_platform && SDL_Has3DNow ()) - || force_platform == SCALEPLAT_3DNOW) + || force_platform == PLATFORM_3DNOW) { log_add (log_Info, "Screen scalers are using 3DNow/MMX code"); Scale_Platform = SCALEPLAT_3DNOW; @@ -237,7 +237,7 @@ } else if ( (!force_platform && SDL_HasMMX ()) - || force_platform == SCALEPLAT_MMX) + || force_platform == PLATFORM_MMX) { log_add (log_Info, "Screen scalers are using MMX code"); Scale_Platform = SCALEPLAT_MMX; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-07 06:17:29
|
Revision: 3690 http://sc2.svn.sourceforge.net/sc2/?rev=3690&view=rev Author: avolkov Date: 2011-09-07 06:17:23 +0000 (Wed, 07 Sep 2011) Log Message: ----------- Update the scripts for cross-building on Cygwin to Mingw with gcc 4 (-mno-cygwin is now gone) Modified Paths: -------------- trunk/sc2/build/unix/config_proginfo_build trunk/sc2/build/unix/config_proginfo_host Modified: trunk/sc2/build/unix/config_proginfo_build =================================================================== --- trunk/sc2/build/unix/config_proginfo_build 2011-09-07 01:01:12 UTC (rev 3689) +++ trunk/sc2/build/unix/config_proginfo_build 2011-09-07 06:17:23 UTC (rev 3690) @@ -142,6 +142,31 @@ BUILDTOOL_LINK_COMMAND="\$PROG_gcce_FILE $EXTRA_GCCE_FLAGS_LINK" BUILDTOOL_LINK_DEPEND='gcce' ;; + CYGWIN*) + EXTRA_CYGWIN_FLAGS_COMPILE='' + EXTRA_CYGWIN_FLAGS_LINK='' + + BUILDTOOL_PREPROC_C_COMMAND="\$PROG_mingw_gcc_FILE -E $EXTRA_CYGWIN_FLAGS_COMPILE" + BUILDTOOL_PREPROC_C_DEPEND='mingw_gcc' + + BUILDTOOL_MKDEP_C_COMMAND="\$PROG_mingw_gcc_FILE -MM $EXTRA_CYGWIN_FLAGS_COMPILE" + BUILDTOOL_MKDEP_C_DEPEND='mingw_gcc' + + BUILDTOOL_COMPILE_C_COMMAND="\$PROG_mingw_gcc_FILE -c $EXTRA_CYGWIN_FLAGS_COMPILE" + BUILDTOOL_COMPILE_C_DEPEND='mingw_gcc' + + BUILDTOOL_PREPROC_OBJC_COMMAND="\$PROG_mingw_gcc_FILE -E" + BUILDTOOL_PREPROC_OBJC_DEPEND='mingw_gcc' + + BUILDTOOL_MKDEP_OBJC_COMMAND="\$PROG_mingw_gcc_FILE -MM" + BUILDTOOL_MKDEP_OBJC_DEPEND='mingw_gcc' + + BUILDTOOL_COMPILE_OBJC_COMMAND="\$PROG_mingw_gcc_FILE -c" + BUILDTOOL_COMPILE_OBJC_DEPEND='mingw_gcc' + + BUILDTOOL_LINK_COMMAND="\$PROG_mingw_gcc_FILE $EXTRA_CYGWIN_FLAGS_LINK" + BUILDTOOL_LINK_DEPEND='mingw_gcc' + ;; *) useGccBuildTools ;; @@ -303,7 +328,13 @@ PROG_gcce_VERSION='$(arm-none-symbianelf-gcc --version)' +### mingw-gcc ### +PROG_mingw_gcc_NAME="GNU C MinGW Cross-compiler" +PROG_mingw_gcc_FILE="i686-pc-mingw32-gcc" +PROG_mingw_gcc_ACTION="" +PROG_mingw_gcc_VERSION='$(i686-pc-mingw32-gcc --version)' + ############################################################################## # Describe the libaries (possibly) used: # ############################################################################## Modified: trunk/sc2/build/unix/config_proginfo_host =================================================================== --- trunk/sc2/build/unix/config_proginfo_host 2011-09-07 01:01:12 UTC (rev 3689) +++ trunk/sc2/build/unix/config_proginfo_host 2011-09-07 06:17:23 UTC (rev 3690) @@ -24,17 +24,7 @@ # CFLAGS -case "$HOST_SYSTEM" in - CYGWIN*) - # HACK: sdl-config on Cygwin supplies -mno-cygwin which means that - # dependencies detected without that flag may not be available at - # the actual build. - SYSTEM_HOST_CFLAGS="-mno-cygwin" - ;; - *) - SYSTEM_HOST_CFLAGS="" - ;; -esac +SYSTEM_HOST_CFLAGS="" # LDFLAGS SYSTEM_HOST_LDFLAGS="" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-07 01:01:18
|
Revision: 3689 http://sc2.svn.sourceforge.net/sc2/?rev=3689&view=rev Author: avolkov Date: 2011-09-07 01:01:12 +0000 (Wed, 07 Sep 2011) Log Message: ----------- Add -O0 to strict debug build type to match others Modified Paths: -------------- trunk/sc2/build/unix/build.config Modified: trunk/sc2/build/unix/build.config =================================================================== --- trunk/sc2/build/unix/build.config 2011-09-06 22:14:20 UTC (rev 3688) +++ trunk/sc2/build/unix/build.config 2011-09-07 01:01:12 UTC (rev 3689) @@ -150,7 +150,7 @@ CFLAGS="$CFLAGS -g -O0 -DDEBUG -D_DEBUG" ;; *) - CFLAGS="$CFLAGS -g -DDEBUG -W -Wall" + CFLAGS="$CFLAGS -g -O0 -DDEBUG -W -Wall" # CFLAGS="$CFLAGS -O1" # This is needed for -Wunitialized with gcc 3.4 CFLAGS="$CFLAGS -Wbad-function-cast -Wcast-qual -Wmissing-prototypes \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-06 22:14:26
|
Revision: 3688 http://sc2.svn.sourceforge.net/sc2/?rev=3688&view=rev Author: avolkov Date: 2011-09-06 22:14:20 +0000 (Tue, 06 Sep 2011) Log Message: ----------- Various strict warnings cleanup, bug #50; from Scott A. Colcord Modified Paths: -------------- trunk/sc2/src/libs/graphics/sdl/opengl.c trunk/sc2/src/libs/graphics/sdl/rotozoom.c trunk/sc2/src/libs/input/sdl/input.c trunk/sc2/src/libs/input/sdl/keynames.c trunk/sc2/src/libs/input/sdl/keynames.h trunk/sc2/src/libs/input/sdl/vcontrol.c trunk/sc2/src/libs/sound/decoders/dukaud.c trunk/sc2/src/libs/sound/decoders/modaud.c trunk/sc2/src/libs/sound/sndintrn.h trunk/sc2/src/libs/sound/sound.h trunk/sc2/src/libs/sound/stream.c trunk/sc2/src/libs/video/vidplayer.c trunk/sc2/src/uqm/weapon.c trunk/sc2/src/uqm.c Modified: trunk/sc2/src/libs/graphics/sdl/opengl.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/opengl.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/graphics/sdl/opengl.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -307,7 +307,7 @@ GL_Screens[TFB_SCREEN_TRANSITION].dirty = TRUE; } -void +static void TFB_GL_ScanLines (void) { int y; Modified: trunk/sc2/src/libs/graphics/sdl/rotozoom.c =================================================================== --- trunk/sc2/src/libs/graphics/sdl/rotozoom.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/graphics/sdl/rotozoom.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -222,6 +222,7 @@ */ +static int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst) { Uint32 sx, sy, *sax, *say, *csax, *csay, csx, csy; @@ -342,6 +343,7 @@ */ +static void transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int smooth) { int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh; @@ -497,6 +499,7 @@ */ +static void transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos) { int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay, sw, sh; @@ -557,6 +560,7 @@ /* Local rotozoom-size function with trig result return */ +static void rotozoomSurfaceSizeTrig(int width, int height, double angle, double zoom, int *dstwidth, int *dstheight, double *canglezoom, double *sanglezoom) { @@ -578,8 +582,8 @@ cy = *canglezoom * y; sx = *sanglezoom * x; sy = *sanglezoom * y; - dstwidthhalf = MAX((int) ceil(fabs(cx) + fabs(sy)), 1); - dstheighthalf = MAX((int) ceil(fabs(sx) + fabs(cy)), 1); + dstwidthhalf = MAX(ceil(fabs(cx) + fabs(sy)), 1); + dstheighthalf = MAX(ceil(fabs(sx) + fabs(cy)), 1); *dstwidth = 2 * dstwidthhalf; *dstheight = 2 * dstheighthalf; } Modified: trunk/sc2/src/libs/input/sdl/input.c =================================================================== --- trunk/sc2/src/libs/input/sdl/input.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/input/sdl/input.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -322,7 +322,7 @@ volatile int MouseButtonDown = 0; -void +static void ProcessMouseEvent (const SDL_Event *e) { switch (e->type) Modified: trunk/sc2/src/libs/input/sdl/keynames.c =================================================================== --- trunk/sc2/src/libs/input/sdl/keynames.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/input/sdl/keynames.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -33,7 +33,7 @@ * tragedy. */ typedef struct vcontrol_keyname { - /* const */ char *name; + const char *name; int code; } keyname; @@ -182,7 +182,7 @@ {"Unknown", 0}}; /* Last element must have code zero */ -char * +const char * VControl_code2name (int code) { int i = 0; @@ -198,12 +198,12 @@ } int -VControl_name2code (char *name) +VControl_name2code (const char *name) { int i = 0; while (1) { - char *test = keynames[i].name; + const char *test = keynames[i].name; int code = keynames[i].code; if (!strcasecmp(test, name) || !code) { Modified: trunk/sc2/src/libs/input/sdl/keynames.h =================================================================== --- trunk/sc2/src/libs/input/sdl/keynames.h 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/input/sdl/keynames.h 2011-09-06 22:14:20 UTC (rev 3688) @@ -17,6 +17,6 @@ #ifndef _KEYNAMES_H_ #define _KEYNAMES_H_ -char *VControl_code2name (int code); -int VControl_name2code (char *code); +const char *VControl_code2name (int code); +int VControl_name2code (const char *code); #endif Modified: trunk/sc2/src/libs/input/sdl/vcontrol.c =================================================================== --- trunk/sc2/src/libs/input/sdl/vcontrol.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/input/sdl/vcontrol.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -184,8 +184,10 @@ key_init (void) { unsigned int i; + int num_keys; // Temp to match type of param for SDL_GetKeyState(). pool = allocate_key_chunk (); - (void)SDL_GetKeyState (&num_sdl_keys); + (void)SDL_GetKeyState (&num_keys); + num_sdl_keys = num_keys; bindings = (keybinding **) HMalloc (sizeof (keybinding *) * num_sdl_keys); for (i = 0; i < num_sdl_keys; i++) bindings[i] = NULL; Modified: trunk/sc2/src/libs/sound/decoders/dukaud.c =================================================================== --- trunk/sc2/src/libs/sound/decoders/dukaud.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/sound/decoders/dukaud.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -105,7 +105,7 @@ static const TFB_DecoderFormats* duka_formats = NULL; -sint32 +static sint32 duka_readAudFrameHeader (TFB_DuckSoundDecoder* duka, uint32 iframe, DukAud_AudSubframe* aud) { @@ -246,7 +246,7 @@ } // *** END part copied from MPlayer *** -sint32 +static sint32 duka_decodeFrame (TFB_DuckSoundDecoder* duka, DukAud_AudSubframe* header, uint8* input) { @@ -273,7 +273,7 @@ } -sint32 +static sint32 duka_readNextFrame (TFB_DuckSoundDecoder* duka) { DukAud_FrameHeader hdr; Modified: trunk/sc2/src/libs/sound/decoders/modaud.c =================================================================== --- trunk/sc2/src/libs/sound/decoders/modaud.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/sound/decoders/modaud.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -88,7 +88,7 @@ static ULONG bufsize; static ULONG written; -ULONG* +static ULONG* moda_mmout_SetOutputBuffer (void* buf, ULONG size) { buffer = buf; @@ -132,12 +132,18 @@ return 0; } +static char MDRIVER_name[] = "Mem Buffer"; +static char MDRIVER_version[] = "Mem Buffer driver v1.1"; +static char MDRIVER_alias[] = "membuf"; + static MDRIVER moda_mmout_drv = -{ NULL, - "Mem Buffer", // Name - "Mem Buffer driver v1.1", // Version - 0, 255, // Voice limits - "membuf", // Alias +{ + NULL, + //xxx libmikmod does not declare these fields const; it probably should. + MDRIVER_name, // Name + MDRIVER_version, // Version + 0, 255, // Voice limits + MDRIVER_alias, // Alias // The minimum mikmod version we support is 3.1.8 #if (LIBMIKMOD_VERSION_MAJOR > 3) || \ @@ -215,7 +221,7 @@ return uio_ftell (((MUIOREADER*)reader)->file); } -MREADER* +static MREADER* moda_new_uioReader (uio_Stream* fp) { MUIOREADER* reader = (MUIOREADER*) HMalloc (sizeof(MUIOREADER)); @@ -231,7 +237,7 @@ return (MREADER*)reader; } -void +static void moda_delete_uioReader (MREADER* reader) { if (reader) Modified: trunk/sc2/src/libs/sound/sndintrn.h =================================================================== --- trunk/sc2/src/libs/sound/sndintrn.h 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/sound/sndintrn.h 2011-09-06 22:14:20 UTC (rev 3688) @@ -46,7 +46,7 @@ uint32 num_buffers; TFB_SoundTag *buffer_tag; sint32 offset; // initial offset - intptr_t data; // user-defined data + void* data; // user-defined data TFB_SoundCallbacks callbacks; // user-defined callbacks }; Modified: trunk/sc2/src/libs/sound/sound.h =================================================================== --- trunk/sc2/src/libs/sound/sound.h 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/sound/sound.h 2011-09-06 22:14:20 UTC (rev 3688) @@ -66,8 +66,8 @@ TFB_SoundSample *TFB_CreateSoundSample (TFB_SoundDecoder*, uint32 num_buffers, const TFB_SoundCallbacks* /* can be NULL */); void TFB_DestroySoundSample (TFB_SoundSample*); -void TFB_SetSoundSampleData (TFB_SoundSample*, intptr_t data); -intptr_t TFB_GetSoundSampleData (TFB_SoundSample*); +void TFB_SetSoundSampleData (TFB_SoundSample*, void* data); +void* TFB_GetSoundSampleData (TFB_SoundSample*); void TFB_SetSoundSampleCallbacks (TFB_SoundSample*, const TFB_SoundCallbacks* /* can be NULL */); TFB_SoundDecoder* TFB_GetSoundSampleDecoder (TFB_SoundSample*); Modified: trunk/sc2/src/libs/sound/stream.c =================================================================== --- trunk/sc2/src/libs/sound/stream.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/sound/stream.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -225,12 +225,12 @@ } void -TFB_SetSoundSampleData (TFB_SoundSample *sample, intptr_t data) +TFB_SetSoundSampleData (TFB_SoundSample *sample, void* data) { sample->data = data; } -intptr_t +void* TFB_GetSoundSampleData (TFB_SoundSample *sample) { return sample->data; Modified: trunk/sc2/src/libs/video/vidplayer.c =================================================================== --- trunk/sc2/src/libs/video/vidplayer.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/libs/video/vidplayer.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -273,7 +273,7 @@ } TFB_SetSoundSampleCallbacks (*vid->hAudio, &vp_AudioCBs); - TFB_SetSoundSampleData (*vid->hAudio, (intptr_t)vid); + TFB_SetSoundSampleData (*vid->hAudio, vid); } // get the first frame @@ -432,7 +432,7 @@ static bool vp_AudioStart (TFB_SoundSample* sample) { - TFB_VideoClip* vid = (TFB_VideoClip*) TFB_GetSoundSampleData (sample); + TFB_VideoClip* vid = TFB_GetSoundSampleData (sample); TFB_SoundDecoder *decoder; assert (sizeof (intptr_t) >= sizeof (vid)); @@ -450,7 +450,7 @@ static void vp_AudioEnd (TFB_SoundSample* sample) { - TFB_VideoClip* vid = (TFB_VideoClip*) TFB_GetSoundSampleData (sample); + TFB_VideoClip* vid = TFB_GetSoundSampleData (sample); assert (vid != NULL); @@ -462,7 +462,7 @@ static void vp_BufferTag (TFB_SoundSample* sample, TFB_SoundTag* tag) { - TFB_VideoClip* vid = (TFB_VideoClip*) TFB_GetSoundSampleData (sample); + TFB_VideoClip* vid = TFB_GetSoundSampleData (sample); uint32 frame = (uint32) tag->data; assert (sizeof (tag->data) >= sizeof (frame)); Modified: trunk/sc2/src/uqm/weapon.c =================================================================== --- trunk/sc2/src/uqm/weapon.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/uqm/weapon.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -31,7 +31,16 @@ #include <stdio.h> +// A wrapper function for weapon_collision that discards the return value. +// This makes its signature match ElementCollisionFunc. +static void +weapon_collision_cb (ELEMENT *WeaponElementPtr, POINT *pWPt, + ELEMENT *HitElementPtr, POINT *pHPt) +{ + weapon_collision (WeaponElementPtr, pWPt, HitElementPtr, pHPt); +} + HELEMENT initialize_laser (LASER_BLOCK *pLaserBlock) { @@ -50,7 +59,7 @@ LaserElementPtr->state_flags = APPEARING | FINITE_LIFE | pLaserBlock->flags; LaserElementPtr->life_span = LASER_LIFE; - LaserElementPtr->collision_func = weapon_collision; + LaserElementPtr->collision_func = weapon_collision_cb; LaserElementPtr->blast_offset = 1; LaserElementPtr->current.location.x = pLaserBlock->cx @@ -100,7 +109,7 @@ SetAbsFrameIndex (pMissileBlock->farray[0], pMissileBlock->index); MissileElementPtr->preprocess_func = pMissileBlock->preprocess_func; - MissileElementPtr->collision_func = weapon_collision; + MissileElementPtr->collision_func = weapon_collision_cb; MissileElementPtr->blast_offset = (BYTE)pMissileBlock->blast_offs; angle = FACING_TO_ANGLE (pMissileBlock->face); Modified: trunk/sc2/src/uqm.c =================================================================== --- trunk/sc2/src/uqm.c 2011-09-06 21:20:40 UTC (rev 3687) +++ trunk/sc2/src/uqm.c 2011-09-06 22:14:20 UTC (rev 3688) @@ -27,6 +27,7 @@ #endif #include <stdarg.h> +#include <errno.h> #include "libs/graphics/gfx_common.h" #include "libs/graphics/cmap.h" #include "libs/sound/sound.h" @@ -279,7 +280,11 @@ if (options.logFile != NULL) { int i; - freopen (options.logFile, "w", stderr); + if (!freopen (options.logFile, "w", stderr)) + { + printf ("Error %d calling freopen() on stderr\n", errno); + return EXIT_FAILURE; + } #ifdef UNBUFFERED_LOGFILE setbuf (stderr, NULL); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-06 21:20:47
|
Revision: 3687 http://sc2.svn.sourceforge.net/sc2/?rev=3687&view=rev Author: avolkov Date: 2011-09-06 21:20:40 +0000 (Tue, 06 Sep 2011) Log Message: ----------- Added -Wdeclaration-after-statement to strict warnings build; removed -O1 not needed for gcc 4; from Scott A. Colcord Modified Paths: -------------- trunk/sc2/build/unix/build.config Modified: trunk/sc2/build/unix/build.config =================================================================== --- trunk/sc2/build/unix/build.config 2011-09-06 17:33:18 UTC (rev 3686) +++ trunk/sc2/build/unix/build.config 2011-09-06 21:20:40 UTC (rev 3687) @@ -150,14 +150,17 @@ CFLAGS="$CFLAGS -g -O0 -DDEBUG -D_DEBUG" ;; *) - CFLAGS="$CFLAGS -O1" # This is needed for -Wunitialized - CFLAGS="$CFLAGS -g -DDEBUG -W -Wall \ - -Wbad-function-cast -Wcast-qual -Wmissing-prototypes \ + CFLAGS="$CFLAGS -g -DDEBUG -W -Wall" +# CFLAGS="$CFLAGS -O1" + # This is needed for -Wunitialized with gcc 3.4 + CFLAGS="$CFLAGS -Wbad-function-cast -Wcast-qual -Wmissing-prototypes \ -Wstrict-prototypes -Wmissing-declarations \ -Wwrite-strings -Wimplicit -Wreturn-type -Wformat \ -Wswitch -Wcomment -Wchar-subscripts \ -Wparentheses -Wcast-align \ -Wuninitialized" + CFLAGS="$CFLAGS -Wdeclaration-after-statement" + # Until we abandon MSVC 6 # CFLAGS="$CFLAGS -Waggregate-return" # It's not unreasonable to return structs at times. # CFLAGS="$CFLAGS "-Wpointer-arith" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-06 17:33:27
|
Revision: 3686 http://sc2.svn.sourceforge.net/sc2/?rev=3686&view=rev Author: avolkov Date: 2011-09-06 17:33:18 +0000 (Tue, 06 Sep 2011) Log Message: ----------- Remove casts from DUCK video decoder which cause function cast warnings Modified Paths: -------------- trunk/sc2/src/libs/video/dukvid.c Modified: trunk/sc2/src/libs/video/dukvid.c =================================================================== --- trunk/sc2/src/libs/video/dukvid.c 2011-09-06 17:27:37 UTC (rev 3685) +++ trunk/sc2/src/libs/video/dukvid.c 2011-09-06 17:33:18 UTC (rev 3686) @@ -727,7 +727,8 @@ //TFB_DuckVideoDecoder* dukv = (TFB_DuckVideoDecoder*) This; uint32 frame = (uint32) (time * DUCK_GENERAL_FPS); - return (float) dukv_SeekFrame (This, frame) / DUCK_GENERAL_FPS; + // Note that DUCK_GENERAL_FPS is a float constant + return dukv_SeekFrame (This, frame) / DUCK_GENERAL_FPS; } static uint32 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-06 17:27:43
|
Revision: 3685 http://sc2.svn.sourceforge.net/sc2/?rev=3685&view=rev Author: avolkov Date: 2011-09-06 17:27:37 +0000 (Tue, 06 Sep 2011) Log Message: ----------- Remove casts from mixer resampling code which cause function cast warnings Modified Paths: -------------- trunk/sc2/src/libs/sound/mixer/mixer.c Modified: trunk/sc2/src/libs/sound/mixer/mixer.c =================================================================== --- trunk/sc2/src/libs/sound/mixer/mixer.c 2011-09-06 17:25:13 UTC (rev 3684) +++ trunk/sc2/src/libs/sound/mixer/mixer.c 2011-09-06 17:27:37 UTC (rev 3685) @@ -1569,7 +1569,7 @@ uint8 *d0 = src->nextqueued->data + src->pos; src->pos += mixer_chansize; (void) left; // satisfying compiler - unused arg - return (float)mixer_GetSampleInt (d0, mixer_chansize); + return mixer_GetSampleInt (d0, mixer_chansize); } /* get a resampled (up/down) sample from source (nearest neighbor) */ @@ -1578,7 +1578,7 @@ { uint8 *d0 = src->nextqueued->data + src->pos; d0 += mixer_SourceAdvance (src, left); - return (float)mixer_GetSampleInt (d0, mixer_chansize); + return mixer_GetSampleInt (d0, mixer_chansize); } /* get an upsampled sample from source (linear interpolation) */ @@ -1608,8 +1608,8 @@ else d1 = d0 + curr->sampsize; - s0 = (float)mixer_GetSampleInt (d0, mixer_chansize); - s1 = (float)mixer_GetSampleInt (d1, mixer_chansize); + s0 = mixer_GetSampleInt (d0, mixer_chansize); + s1 = mixer_GetSampleInt (d1, mixer_chansize); return s0 + t * (s1 - s0); } @@ -1672,10 +1672,10 @@ d3 = d2 + curr->sampsize; } - s0 = (float)mixer_GetSampleInt (d0, mixer_chansize); - s1 = (float)mixer_GetSampleInt (d1, mixer_chansize); - s2 = (float)mixer_GetSampleInt (d2, mixer_chansize); - s3 = (float)mixer_GetSampleInt (d3, mixer_chansize); + s0 = mixer_GetSampleInt (d0, mixer_chansize); + s1 = mixer_GetSampleInt (d1, mixer_chansize); + s2 = mixer_GetSampleInt (d2, mixer_chansize); + s3 = mixer_GetSampleInt (d3, mixer_chansize); a = (3.0f * (s1 - s2) - s0 + s3) * 0.5f; b = 2.0f * s2 + s0 - ((5.0f * s1 + s3) * 0.5f); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-06 17:25:19
|
Revision: 3684 http://sc2.svn.sourceforge.net/sc2/?rev=3684&view=rev Author: avolkov Date: 2011-09-06 17:25:13 +0000 (Tue, 06 Sep 2011) Log Message: ----------- Sort out the inplib SDL includes Modified Paths: -------------- trunk/sc2/src/libs/input/sdl/input.c trunk/sc2/src/libs/input/sdl/input.h Modified: trunk/sc2/src/libs/input/sdl/input.c =================================================================== --- trunk/sc2/src/libs/input/sdl/input.c 2011-09-05 16:16:41 UTC (rev 3683) +++ trunk/sc2/src/libs/input/sdl/input.c 2011-09-06 17:25:13 UTC (rev 3684) @@ -18,8 +18,10 @@ #include <assert.h> #include <errno.h> +#include <string.h> +#include "input.h" #include "../inpintrn.h" -#include "libs/graphics/sdl/sdl_common.h" +#include "libs/threadlib.h" #include "libs/input/sdl/vcontrol.h" #include "libs/input/sdl/keynames.h" #include "libs/memlib.h" Modified: trunk/sc2/src/libs/input/sdl/input.h =================================================================== --- trunk/sc2/src/libs/input/sdl/input.h 2011-09-05 16:16:41 UTC (rev 3683) +++ trunk/sc2/src/libs/input/sdl/input.h 2011-09-06 17:25:13 UTC (rev 3684) @@ -19,6 +19,9 @@ #ifndef INPUT_H #define INPUT_H +#include "port.h" +#include SDL_INCLUDE(SDL.h) + extern void ProcessInputEvent (const SDL_Event *Event); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2011-09-05 16:16:47
|
Revision: 3683 http://sc2.svn.sourceforge.net/sc2/?rev=3683&view=rev Author: avolkov Date: 2011-09-05 16:16:41 +0000 (Mon, 05 Sep 2011) Log Message: ----------- Fix transposed memset() parameters in aiff decoder Modified Paths: -------------- trunk/sc2/src/libs/sound/decoders/aiffaud.c Modified: trunk/sc2/src/libs/sound/decoders/aiffaud.c =================================================================== --- trunk/sc2/src/libs/sound/decoders/aiffaud.c 2011-09-05 16:10:56 UTC (rev 3682) +++ trunk/sc2/src/libs/sound/decoders/aiffaud.c 2011-09-05 16:16:41 UTC (rev 3683) @@ -307,7 +307,7 @@ { int bytes; - memset(fmt, sizeof(*fmt), 0); + memset(fmt, 0, sizeof(*fmt)); if (size < AIFF_COMM_SIZE) { aifa->last_error = aifae_BadFile; @@ -369,7 +369,7 @@ aifa->max_pcm = 0; aifa->data_ofs = 0; memset(&aifa->fmtHdr, 0, sizeof(aifa->fmtHdr)); - memset(aifa->prev_val, sizeof(aifa->prev_val), 0); + memset(aifa->prev_val, 0, sizeof(aifa->prev_val)); // read wave header if (!aifa_readFileHeader (aifa, &fileHdr)) @@ -635,7 +635,7 @@ // reset previous values for SDX2 on seek ops // the delta will recover faster with reset - memset(aifa->prev_val, sizeof(aifa->prev_val), 0); + memset(aifa->prev_val, 0, sizeof(aifa->prev_val)); return pcm_pos; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |