misc.c
changeset 1328 eacd8225ed42
parent 1313 f1013ec3d318
child 1375 00a24560f025
equal deleted inserted replaced
1327:6e507eb10edd 1328:eacd8225ed42
    13 #include "engine.h"
    13 #include "engine.h"
    14 
    14 
    15 extern void StartupEconomy(void);
    15 extern void StartupEconomy(void);
    16 extern void InitNewsItemStructs(void);
    16 extern void InitNewsItemStructs(void);
    17 
    17 
    18 byte _name_array[512][32];
    18 char _name_array[512][32];
    19 
    19 
    20 static inline uint32 ROR(uint32 x, int n)
    20 static inline uint32 ROR(uint32 x, int n)
    21 {
    21 {
    22 	return (x >> n) + (x << ((sizeof(x)*8)-n));
    22 	return (x >> n) + (x << ((sizeof(x)*8)-n));
    23 }
    23 }
   304 	if ((id & 0xF800) == 0x7800) {
   304 	if ((id & 0xF800) == 0x7800) {
   305 		memset(_name_array[id & 0x1FF], 0, sizeof(_name_array[id & 0x1FF]));
   305 		memset(_name_array[id & 0x1FF], 0, sizeof(_name_array[id & 0x1FF]));
   306 	}
   306 	}
   307 }
   307 }
   308 
   308 
   309 byte *GetName(int id, byte *buff)
   309 char *GetName(int id, char *buff)
   310 {
   310 {
   311 	byte *b;
   311 	const char *b;
   312 
   312 
   313 	if (id & 0x600) {
   313 	if (id & 0x600) {
   314 		if (id & 0x200) {
   314 		if (id & 0x200) {
   315 			if (id & 0x400) {
   315 			if (id & 0x400) {
   316 				GetParamInt32();
   316 				GetParamInt32();
   339 static void InitializeNameMgr(void)
   339 static void InitializeNameMgr(void)
   340 {
   340 {
   341 	memset(_name_array, 0, sizeof(_name_array));
   341 	memset(_name_array, 0, sizeof(_name_array));
   342 }
   342 }
   343 
   343 
   344 StringID RealAllocateName(const byte *name, byte skip, bool check_double)
   344 StringID RealAllocateName(const char *name, byte skip, bool check_double)
   345 {
   345 {
   346 	int free_item = -1;
   346 	int free_item = -1;
   347 	const byte *names;
   347 	const char *names;
   348 	byte *dst;
   348 	char *dst;
   349 	int i;
   349 	int i;
   350 
   350 
   351 	names = &_name_array[0][0];
   351 	names = &_name_array[0][0];
   352 
   352 
   353 	for(i=0; i!=512; i++,names+=sizeof(_name_array[0])) {
   353 	for(i=0; i!=512; i++,names+=sizeof(_name_array[0])) {
   742 }
   742 }
   743 
   743 
   744 static void Save_NAME(void)
   744 static void Save_NAME(void)
   745 {
   745 {
   746 	int i;
   746 	int i;
   747 	byte *b = _name_array[0];
   747 	char *b = _name_array[0];
   748 
   748 
   749 	for(i=0; i!=lengthof(_name_array); i++,b+=sizeof(_name_array[0])) {
   749 	for(i=0; i!=lengthof(_name_array); i++,b+=sizeof(_name_array[0])) {
   750 		if (*b) {
   750 		if (*b) {
   751 			SlSetArrayIndex(i);
   751 			SlSetArrayIndex(i);
   752 			SlArray(b, strlen(b), SLE_UINT8);
   752 			SlArray(b, strlen(b), SLE_UINT8);