Changeset - r1:d67833cf1719
[Not reviewed]
master
0 9 0
darkvater - 20 years ago 2004-08-10 14:14:00
darkvater@openttd.org
(svn r2) -Fix [993829] UDP Fixes (lucaspiller)
-Fix change 255/0xFF to OWNER_SPECTATOR for
spectator stuff (TrueLight)
9 files changed with 41 insertions and 24 deletions:
0 comments (0 inline, 0 general)
functions.h
Show inline comments
 
@@ -126,7 +126,7 @@ void NetworkReceive();
 
void NetworkSend();
 
void NetworkProcessCommands();
 
void NetworkListen(int port);
 
void NetworkInitialize();
 
void NetworkInitialize(const char *hostname);
 
void NetworkShutdown();
 
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
 
void NetworkStartSync();
main_gui.c
Show inline comments
 
@@ -597,7 +597,7 @@ static Window *PopupMainPlayerToolbMenu(
 
	w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
 
	w->flags4 &= ~WF_WHITE_BORDER_MASK;
 
	WP(w,menu_d).item_count = 0;
 
	WP(w,menu_d).sel_index = _local_player != 0xff ? _local_player : 0;
 
	WP(w,menu_d).sel_index = _local_player != OWNER_SPECTATOR ? _local_player : 0;
 
	WP(w,menu_d).action_id = main_button;
 
	WP(w,menu_d).main_button = main_button;
 
	WP(w,menu_d).checked_items = gray;
 
@@ -1633,7 +1633,7 @@ static void MainToolbarWndProc(Window *w
 
		GfxFillRect(0, 0, w->width-1, w->height-1, 0x80B4);
 

	
 
		// if spectator, disable things
 
		if (_current_player == 0xff){
 
		if (_current_player == OWNER_SPECTATOR){
 
			w->disabled_state |= (1 << 0) | (1 << 19) | (1<<20) | (1<<21) | (1<<22) | (1<<23);
 
		} else {
 
			w->disabled_state &= ~((1 << 0) | (1 << 19) | (1<<20) | (1<<21) | (1<<22) | (1<<23));
 
@@ -1965,7 +1965,7 @@ void StatusBarWndProc(Window *w, WindowE
 
		SET_DPARAM16(0, _date);
 
		DrawStringCentered(70, 1, ((_pause||_patches.status_long_date)?STR_00AF:STR_00AE), 0);
 
		
 
		p = _local_player == 0xff ? NULL : DEREF_PLAYER(_local_player);
 
		p = _local_player == OWNER_SPECTATOR ? NULL : DEREF_PLAYER(_local_player);
 

	
 
		if (p) {
 
			// Draw player money
 
@@ -1996,7 +1996,7 @@ void StatusBarWndProc(Window *w, WindowE
 
		if (e->click.widget == 1) {
 
			ShowLastNewsMessage();
 
		} else if (e->click.widget == 2) {
 
			if (_local_player != 0xff) ShowPlayerFinances(_local_player);
 
			if (_local_player != OWNER_SPECTATOR) ShowPlayerFinances(_local_player);
 
		} else {
 
			ResetObjectToPlace();
 
		}
network.c
Show inline comments
 
@@ -482,13 +482,13 @@ static void HandleFilePacket(FilePacketH
 
			// send a command to make a new player
 
			_local_player = 0;
 
			NetworkSendCommand(0, 0, 0, CMD_PLAYER_CTRL, NULL);
 
			_local_player = 0xff;
 
			_local_player = OWNER_SPECTATOR;
 
		} else {
 
			// take control over an existing company
 
			if (DEREF_PLAYER(_network_playas-1)->is_active)
 
				_local_player = _network_playas-1;
 
			else
 
				_local_player = 0xff;
 
				_local_player = OWNER_SPECTATOR;
 
		}
 

	
 
	} else {
 
@@ -971,9 +971,10 @@ void NetworkListen(int port)
 
	_listensocket = ls;
 
}
 

	
 
void NetworkInitialize()
 
void NetworkInitialize(const char *hostname)
 
{
 
	ClientState *cs;
 

	
 
#if defined(WIN32)
 
	WSADATA wsa;
 
	if (WSAStartup(MAKEWORD(2,0), &wsa) != 0)
 
@@ -993,8 +994,15 @@ void NetworkInitialize()
 
	for(cs=_clients; cs != &_clients[MAX_CLIENTS]; cs++)
 
		cs->socket = INVALID_SOCKET;
 
	
 
	// startup udp listener
 
	NetworkUDPListen(_network_port);
 
	/*	startup udp listener
 
	 *	- only if this instance is a server, so clients can find it
 
	 *	OR
 
	 *  - a client, wanting to find a server to connect to
 
	 */
 
	if (hostname == NULL  || strcmp(hostname,"auto") == 0) {
 
		printf("Trying to open UDP port...\n");		
 
		NetworkUDPListen(_network_port);
 
	}
 
}
 

	
 
void NetworkShutdown()
 
@@ -1168,7 +1176,7 @@ bool NetworkUDPSearchServer() {
 
#else // ENABLE_NETWORK
 

	
 
// stubs
 
void NetworkInitialize() {}
 
void NetworkInitialize(const char *hostname) {}
 
void NetworkShutdown() {}
 
void NetworkListen(int port) {}
 
void NetworkConnect(const char *hostname, int port) {}
network_gui.c
Show inline comments
 
@@ -26,7 +26,7 @@ void ConnectToServer(byte* b)
 
{
 
	_networking = true;
 
	
 
	NetworkInitialize();
 
	NetworkInitialize(b);
 
	DEBUG(misc, 1) ("Connecting to %s %d\n", b, _network_port);
 
	NetworkConnect(b, _network_port);
 
}
 
@@ -177,7 +177,7 @@ void ShowNetworkGameWindow()
 
void StartServer()
 
{
 
	_networking = true;
 
	NetworkInitialize();
 
	NetworkInitialize(NULL);
 
	DEBUG(misc, 1) ("Listening on port %d\n", _network_port);
 
	NetworkListen(_network_port);
 
	_networking_server = true;
players.c
Show inline comments
 
@@ -581,7 +581,7 @@ void PlayersYearlyLoop()
 
		}
 
	}
 

	
 
	if (_patches.show_finances && _local_player != 0xff) {
 
	if (_patches.show_finances && _local_player != OWNER_SPECTATOR) {
 
		ShowPlayerFinances(_local_player);
 
		p = DEREF_PLAYER(_local_player);
 
		if (p->num_valid_stat_ent > 5 && p->old_economy[0].performance_history < p->old_economy[4].performance_history) {
 
@@ -632,7 +632,7 @@ int32 CmdPlayerCtrl(int x, int y, uint32
 
	switch(p1 & 0xff) {
 
	case 0: // make new player
 
		p = DoStartupNewPlayer(false);
 
		if (_local_player == 0xff && p != NULL) {
 
		if (_local_player == OWNER_SPECTATOR && p != NULL) {
 
			_local_player = p->index;
 
			MarkWholeScreenDirty();
 
		}
screenshot.c
Show inline comments
 
@@ -422,7 +422,7 @@ static char *MakeScreenshotName(const ch
 
	char *base;
 
	int serial;
 

	
 
	if (_game_mode == GM_EDITOR || _local_player == 0xff) {
 
	if (_game_mode == GM_EDITOR || _local_player == OWNER_SPECTATOR) {
 
		sprintf(_screenshot_name, "screenshot");
 
	} else {
 
		Player *p = &_players[_local_player];
town_gui.c
Show inline comments
 
@@ -29,7 +29,7 @@ static uint GetMaskOfTownActions(int *nu
 
	uint avail_buttons = 0x7F; // by default all buttons except bribe are enabled.
 
	uint buttons;
 

	
 
	if (_local_player != 0xff) {
 
	if (_local_player != OWNER_SPECTATOR) {
 
		// bribe option enabled?
 
		if (_patches.bribe) {
 
			// if unwanted, disable everything.
ttd.c
Show inline comments
 
@@ -489,7 +489,15 @@ int ttd_main(int argc, char* argv[])
 
		case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break;
 
		case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break;
 
		case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break;
 
		case 'n': network=1; if (mgo.opt) {network_conn = mgo.opt; network++;} break;
 
		case 'n': {
 
				network = 1; 
 
				if ((bool)mgo.opt) {
 
					network_conn = mgo.opt; 
 
					network++;
 
				}
 
				else
 
					network_conn = NULL;
 
			} break;
 
		case 'r': ParseResolution(resolution, mgo.opt); break;
 
		case 'l': {
 
				language = mgo.opt;
 
@@ -518,7 +526,7 @@ int ttd_main(int argc, char* argv[])
 
			break;
 
		case 'p': {
 
			int i = atoi(mgo.opt);
 
			if (IS_INT_INSIDE(i, 0, 8))	_network_playas = i + 1;
 
			if (IS_INT_INSIDE(i, 0, MAX_PLAYERS))	_network_playas = i + 1;
 
			break;
 
		}
 
		case -2:
 
@@ -573,7 +581,7 @@ int ttd_main(int argc, char* argv[])
 
	if (network) {
 
		_networking = true;
 
		
 
		NetworkInitialize();
 
		NetworkInitialize(network_conn);
 
		if (network==1) {
 
			DEBUG(misc, 1) ("Listening on port %d\n", _network_port);
 
			NetworkListen(_network_port);
 
@@ -875,7 +883,7 @@ static void DoAutosave()
 
{
 
	char buf[200];
 
	
 
	if (_patches.keep_all_autosave && _local_player != 255) {
 
	if (_patches.keep_all_autosave && _local_player != OWNER_SPECTATOR) {
 
		Player *p;
 
		char *s;
 
		sprintf(buf, "%s%s", _path.autosave_dir, PATHSEP);
ttd.h
Show inline comments
 
@@ -469,9 +469,10 @@ enum Sprites {
 
};
 

	
 
enum MAP_OWNERS {
 
	OWNER_TOWN = 0xf, // a town owns the tile
 
	OWNER_NONE = 0x10,// nobody owns the tile
 
	OWNER_WATER= 0x11,// "water" owns the tile
 
	OWNER_TOWN			= 0xf, // a town owns the tile
 
	OWNER_NONE			= 0x10,// nobody owns the tile
 
	OWNER_WATER			= 0x11,// "water" owns the tile
 
	OWNER_SPECTATOR	= 0xff, // spectator in MP or in scenario editor
 
};
 

	
 
VARDEF bool _savegame_sort_dirty;
0 comments (0 inline, 0 general)