diff --git a/code/network/multi_pxo.cpp b/code/network/multi_pxo.cpp index 349722159ab..8a97355409e 100644 --- a/code/network/multi_pxo.cpp +++ b/code/network/multi_pxo.cpp @@ -3202,6 +3202,11 @@ void multi_pxo_chat_process() char msg[512]; int msg_pixel_width; + // Bail if the input box is not ready to go + if (!Multi_pxo_chat_input.is_valid()) { + return; + } + // if the chat line is getting too long, fire off the message, putting the last // word on the next input line. memset(msg, 0, 512); diff --git a/code/ui/inputbox.cpp b/code/ui/inputbox.cpp index 97cc593712a..a735b9de0a9 100644 --- a/code/ui/inputbox.cpp +++ b/code/ui/inputbox.cpp @@ -131,6 +131,7 @@ void UI_INPUTBOX::create(UI_WINDOW *wnd, int _x, int _y, int _w, int _text_len, locked = 0; valid_chars = NULL; invalid_chars = NULL; + valid = true; } void UI_INPUTBOX::set_valid_chars(const char *vchars) @@ -183,6 +184,8 @@ void UI_INPUTBOX::destroy() passwd_text = NULL; } + valid = false; + UI_GADGET::destroy(); } @@ -497,6 +500,11 @@ int UI_INPUTBOX::pressed() return pressed_down; } +bool UI_INPUTBOX::is_valid() +{ + return valid; +} + void UI_INPUTBOX::get_text(char *out, size_t max_out_len) { strncpy(out, text, max_out_len); diff --git a/code/ui/ui.h b/code/ui/ui.h index fe296f8ba5f..d25c6f2dd5a 100644 --- a/code/ui/ui.h +++ b/code/ui/ui.h @@ -293,6 +293,7 @@ class UI_INPUTBOX : public UI_GADGET color *text_color; char *valid_chars; char *invalid_chars; + bool valid; // is invalid until created and then is valid until destroyed // cursor drawing int cursor_first_frame; @@ -392,6 +393,11 @@ class UI_INPUTBOX : public UI_GADGET */ int pressed(); + /** + * @brief Returns true if valid + */ + bool is_valid(); + /** * @brief Retrieves the string currently in the inputbox * @param[out] out Destination char[] to copy the string to