Changeset - r1328:7f615de66cc5
[Not reviewed]
master
0 11 0
tron - 19 years ago 2005-02-06 20:53:31
tron@openttd.org
(svn r1832) Next byte -> char iteration: custom names
11 files changed with 23 insertions and 23 deletions:
0 comments (0 inline, 0 general)
engine.c
Show inline comments
 
@@ -813,13 +813,13 @@ void EnginesMonthlyLoop(void)
 
}
 

	
 
int32 CmdRenameEngine(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID str;
 

	
 
	str = AllocateNameUnique((byte*)_decode_parameters, 0);
 
	str = AllocateNameUnique((const char*)_decode_parameters, 0);
 
	if (str == 0)
 
		return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		StringID old_str = _engine_name_strings[p1];
 
		_engine_name_strings[p1] = str;
functions.h
Show inline comments
 
@@ -156,19 +156,19 @@ void NetworkSend_Command(uint32 tile, ui
 
void PlaceTreesRandomly(void);
 

	
 
void InitializeLandscapeVariables(bool only_constants);
 

	
 
/* misc.c */
 
void DeleteName(StringID id);
 
byte *GetName(int id, byte *buff);
 
char *GetName(int id, char *buff);
 

	
 
// AllocateNameUnique also tests if the name used is not used anywere else
 
//  and if it is used, it returns an error.
 
#define AllocateNameUnique(name, skip) RealAllocateName(name, skip, true)
 
#define AllocateName(name, skip) RealAllocateName(name, skip, false)
 
StringID RealAllocateName(const byte *name, byte skip, bool check_double);
 
StringID RealAllocateName(const char *name, byte skip, bool check_double);
 
void ConvertDayToYMD(YearMonthDay *ymd, uint16 date);
 
uint ConvertYMDToDay(uint year, uint month, uint day);
 
uint ConvertIntDate(uint date);
 
void CSleep(int milliseconds);
 

	
 

	
misc.c
Show inline comments
 
@@ -12,13 +12,13 @@
 
#include "network_server.h"
 
#include "engine.h"
 

	
 
extern void StartupEconomy(void);
 
extern void InitNewsItemStructs(void);
 

	
 
byte _name_array[512][32];
 
char _name_array[512][32];
 

	
 
static inline uint32 ROR(uint32 x, int n)
 
{
 
	return (x >> n) + (x << ((sizeof(x)*8)-n));
 
}
 

	
 
@@ -303,15 +303,15 @@ void DeleteName(StringID id)
 
{
 
	if ((id & 0xF800) == 0x7800) {
 
		memset(_name_array[id & 0x1FF], 0, sizeof(_name_array[id & 0x1FF]));
 
	}
 
}
 

	
 
byte *GetName(int id, byte *buff)
 
char *GetName(int id, char *buff)
 
{
 
	byte *b;
 
	const char *b;
 

	
 
	if (id & 0x600) {
 
		if (id & 0x200) {
 
			if (id & 0x400) {
 
				GetParamInt32();
 
				GetParamUint16();
 
@@ -338,17 +338,17 @@ static void InitializeCheats(void)
 

	
 
static void InitializeNameMgr(void)
 
{
 
	memset(_name_array, 0, sizeof(_name_array));
 
}
 

	
 
StringID RealAllocateName(const byte *name, byte skip, bool check_double)
 
StringID RealAllocateName(const char *name, byte skip, bool check_double)
 
{
 
	int free_item = -1;
 
	const byte *names;
 
	byte *dst;
 
	const char *names;
 
	char *dst;
 
	int i;
 

	
 
	names = &_name_array[0][0];
 

	
 
	for(i=0; i!=512; i++,names+=sizeof(_name_array[0])) {
 
		if (names[0] == 0) {
 
@@ -741,13 +741,13 @@ void bubblesort(void *base, size_t nmemb
 
	buffer = NULL;
 
}
 

	
 
static void Save_NAME(void)
 
{
 
	int i;
 
	byte *b = _name_array[0];
 
	char *b = _name_array[0];
 

	
 
	for(i=0; i!=lengthof(_name_array); i++,b+=sizeof(_name_array[0])) {
 
		if (*b) {
 
			SlSetArrayIndex(i);
 
			SlArray(b, strlen(b), SLE_UINT8);
 
		}
misc_cmd.c
Show inline comments
 
@@ -123,13 +123,13 @@ int32 CmdDecreaseLoan(int x, int y, uint
 

	
 
int32 CmdChangeCompanyName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID str,old_str;
 
	Player *p;
 

	
 
	str = AllocateNameUnique((byte*)_decode_parameters, 4);
 
	str = AllocateNameUnique((const char*)_decode_parameters, 4);
 
	if (str == 0)
 
		return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		p = DEREF_PLAYER(p1);
 
		old_str = p->name_1;
 
@@ -145,13 +145,13 @@ int32 CmdChangeCompanyName(int x, int y,
 

	
 
int32 CmdChangePresidentName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID str,old_str;
 
	Player *p;
 

	
 
	str = AllocateNameUnique((byte*)_decode_parameters, 4);
 
	str = AllocateNameUnique((const char*)_decode_parameters, 4);
 
	if (str == 0)
 
		return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		p = DEREF_PLAYER(p1);
 
		old_str = p->president_name_1;
network_gui.c
Show inline comments
 
@@ -272,41 +272,41 @@ static void NetworkGameWindowWndProc(Win
 

	
 
				DeleteName(_str_game_name);
 
				DeleteName(_str_map_name);
 
				DeleteName(_str_server_version);
 
				DeleteName(_str_server_address);
 
				if (_selected_item->info.server_name[0] != '\0')
 
					_str_game_name = AllocateName((byte*) _selected_item->info.server_name, 0);
 
					_str_game_name = AllocateName(_selected_item->info.server_name, 0);
 
				else
 
					_str_game_name = STR_EMPTY;
 

	
 
				if (_selected_item->info.map_name[0] != '\0')
 
					_str_map_name = AllocateName((byte*) _selected_item->info.map_name, 0);
 
					_str_map_name = AllocateName(_selected_item->info.map_name, 0);
 
				else
 
					_str_map_name = STR_EMPTY;
 

	
 
				if (_selected_item->info.server_revision[0] != '\0')
 
					_str_server_version = AllocateName((byte*) _selected_item->info.server_revision, 0);
 
					_str_server_version = AllocateName(_selected_item->info.server_revision, 0);
 
				else
 
					_str_server_version = STR_EMPTY;
 

	
 
				if (_selected_item->info.hostname[0] != '\0')
 
					_str_server_address = AllocateName((byte*) _selected_item->info.hostname, 0);
 
					_str_server_address = AllocateName(_selected_item->info.hostname, 0);
 
				else
 
					_str_server_address = STR_EMPTY;
 
			}
 
			SetWindowDirty(w);
 
		} break;
 
		case 11: /* Find server automatically */
 
			switch (_network_lan_internet) {
 
				case 0: NetworkUDPSearchGame(); break;
 
				case 1: NetworkUDPQueryMasterServer(); break;
 
			}
 
			break;
 
		case 12: { // Add a server
 
				StringID str = AllocateName((byte*)_network_default_ip, 0);
 
				StringID str = AllocateName(_network_default_ip, 0);
 

	
 
				ShowQueryString(
 
				str,
 
				STR_NETWORK_ENTER_IP,
 
				31 | 0x1000,  // maximum number of characters OR
 
				250, // characters up to this width pixels, whichever is satisfied first
oldloader.c
Show inline comments
 
@@ -459,13 +459,13 @@ static void FixOldVehicles(void)
 
   Old Towns are 94 bytes big
 
   Old Orders are 2 bytes big */
 
#define REMAP_TOWN_IDX(x) ((x) - (0x0459154 - 0x0458EF0)) / 94
 
#define REMAP_ORDER_IDX(x) ((x) - (0x045AB08 - 0x0458EF0)) / 2
 

	
 
extern TileIndex _animated_tile_list[256];
 
extern byte _name_array[512][32];
 
extern char _name_array[512][32];
 
extern uint16 _custom_sprites_base;
 

	
 
static byte   _old_vehicle_multipler;
 
static uint8  _old_map3[OLD_MAP_SIZE * 2];
 
static bool   _new_ttdpatch_format;
 
static uint32 _old_town_index;
rail_cmd.c
Show inline comments
 
@@ -837,13 +837,13 @@ int32 CmdRemoveTrainWaypoint(int x, int 
 
int32 CmdRenameWaypoint(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Waypoint *cp;
 
	StringID str;
 

	
 
	if (_decode_parameters[0] != 0) {
 
		str = AllocateNameUnique((byte*)_decode_parameters, 0);
 
		str = AllocateNameUnique((const char*)_decode_parameters, 0);
 
		if (str == 0) return CMD_ERROR;
 

	
 
		if (flags & DC_EXEC) {
 
			cp = &_waypoints[p1];
 
			if (~cp->town_or_string & 0xC000) DeleteName(cp->town_or_string);
 
			cp->town_or_string = str;
signs.c
Show inline comments
 
@@ -129,13 +129,13 @@ int32 CmdRenameSign(int x, int y, uint32
 
	StringID str;
 
	SignStruct *ss;
 

	
 
	/* If GetDParam(0) == nothing, we delete the sign */
 
	if (GetDParam(0) != 0 && owner != OWNER_NONE) {
 
		/* Create the name */
 
		str = AllocateName((byte*)_decode_parameters, 0);
 
		str = AllocateName((const char*)_decode_parameters, 0);
 
		if (str == 0)
 
			return CMD_ERROR;
 

	
 
		if (flags & DC_EXEC) {
 
			ss = GetSign(sign_id);
 

	
station_cmd.c
Show inline comments
 
@@ -2649,13 +2649,13 @@ static void UpdateStationWaiting(Station
 

	
 
int32 CmdRenameStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID str,old_str;
 
	Station *st;
 

	
 
	str = AllocateNameUnique((byte*)_decode_parameters, 6);
 
	str = AllocateNameUnique((const char*)_decode_parameters, 6);
 
	if (str == 0)
 
		return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		st = GetStation(p1);
 
		old_str = st->string_id;
town_cmd.c
Show inline comments
 
@@ -1392,13 +1392,13 @@ static void ClearTownHouse(Town *t, uint
 

	
 
int32 CmdRenameTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID str;
 
	Town *t = GetTown(p1);
 

	
 
	str = AllocateNameUnique((byte*)_decode_parameters, 4);
 
	str = AllocateNameUnique((const char*)_decode_parameters, 4);
 
	if (str == 0)
 
		return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		StringID old_str = t->townnametype;
 
		t->townnametype = str;
vehicle.c
Show inline comments
 
@@ -1609,13 +1609,13 @@ int32 CmdNameVehicle(int x, int y, uint3
 

	
 
	v = GetVehicle(p1);
 

	
 
	if (!CheckOwnership(v->owner))
 
		return CMD_ERROR;
 

	
 
	str = AllocateNameUnique((byte*)_decode_parameters, 2);
 
	str = AllocateNameUnique((const char*)_decode_parameters, 2);
 
	if (str == 0)
 
		return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		StringID old_str = v->string_id;
 
		v->string_id = str;
0 comments (0 inline, 0 general)