Changeset - r5672:9642b28d8d67
[Not reviewed]
master
0 1 0
Darkvater - 17 years ago 2007-01-14 21:32:13
darkvater@openttd.org
(svn r8132) -Fix (r6824): The game could crash when the chat key (<ENTER>) is pressed too vehemently during the join of the game. Your client's id does not exist in the clients list yet, and returns NULL.
1 file changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/main_gui.cpp
Show inline comments
 
@@ -2281,71 +2281,75 @@ static void MainWindowWndProc(Window *w,
 
				break;
 

	
 
			case '1' | WKC_ALT: /* Gimme money */
 
				/* Server can not cheat in advertise mode either! */
 
				if (!_networking || !_network_server || !_network_advertise)
 
					DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT);
 
				break;
 

	
 
			case '2' | WKC_ALT: /* Update the coordinates of all station signs */
 
				UpdateAllStationVirtCoord();
 
				break;
 
#endif
 

	
 
			case 'X':
 
				_display_opt ^= DO_TRANS_BUILDINGS;
 
				MarkWholeScreenDirty();
 
				break;
 

	
 
#ifdef ENABLE_NETWORK
 
			case WKC_RETURN: case 'T': // smart chat; send to team if any, otherwise to all
 
				if (_networking) {
 
					const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
 
					bool teamchat = false;
 

	
 
					if (cio == NULL) break;
 

	
 
					/* Only players actually playing can speak to team. Eg spectators cannot */
 
					if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
 
						const NetworkClientInfo *ci;
 
						FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
 
							if (ci->client_playas == cio->client_playas && ci != cio) {
 
								teamchat = true;
 
								break;
 
							}
 
						}
 
					}
 

	
 
					ShowNetworkChatQueryWindow(teamchat ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas);
 
				}
 
				break;
 

	
 
			case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all players
 
				if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0);
 
				break;
 

	
 
			case WKC_CTRL | WKC_RETURN: case WKC_CTRL | 'T': // send text to all team mates
 
				if (_networking) {
 
					const NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
 
					ShowNetworkChatQueryWindow(DESTTYPE_TEAM, ci->client_playas);
 
					const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
 
					if (cio == NULL) break;
 

	
 
					ShowNetworkChatQueryWindow(DESTTYPE_TEAM, cio->client_playas);
 
				}
 
				break;
 
#endif
 

	
 
			default: return;
 
		}
 
		e->we.keypress.cont = false;
 
		break;
 

	
 
		case WE_SCROLL: {
 
			ViewPort *vp = IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y);
 

	
 
			if (vp == NULL) {
 
				_cursor.fix_at = false;
 
				_scrolling_viewport = false;
 
			}
 

	
 
			WP(w, vp_d).scrollpos_x += e->we.scroll.delta.x << vp->zoom;
 
			WP(w, vp_d).scrollpos_y += e->we.scroll.delta.y << vp->zoom;
 
		} break;
 

	
 
		case WE_MOUSEWHEEL:
 
			ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w);
 
			break;
0 comments (0 inline, 0 general)