Fix crash if selected index is -1 in lava map settings in gui.

This commit is contained in:
UnknownShadow200 2016-09-12 15:13:02 +10:00
parent 4076a8f9d3
commit ff0932ad22
3 changed files with 10 additions and 6 deletions

View File

@ -81,7 +81,7 @@ namespace MCGalaxy.Commands {
; ;
} }
p.trainGrab = false; p.trainGrab = false;
Player.Message(p, "Dismounted"); Player.Message(p, "Dismounted");
Thread.Sleep(1000); Thread.Sleep(1000);
p.trainInvincible = false; p.trainInvincible = false;

View File

@ -156,14 +156,19 @@ namespace MCGalaxy.Gui {
private void lsMapUse_SelectedIndexChanged(object sender, EventArgs e) { private void lsMapUse_SelectedIndexChanged(object sender, EventArgs e) {
SaveLavaMapSettings(); SaveLavaMapSettings();
if (lsMapUse.SelectedIndex == -1) {
groupBox22.Text = "Map settings";
pg_lavaMap.SelectedObject = null;
return;
}
string name = lsMapUse.Items[lsMapUse.SelectedIndex].ToString(); string name = lsMapUse.Items[lsMapUse.SelectedIndex].ToString();
lsLoadedMap = name;
groupBox22.Text = "Map settings (" + name + ")"; groupBox22.Text = "Map settings (" + name + ")";
try { try {
LavaSurvival.MapSettings m = Server.lava.LoadMapSettings(name); LavaSurvival.MapSettings m = Server.lava.LoadMapSettings(name);
pg_lavaMap.SelectedObject = new LavaMapProperties(m); pg_lavaMap.SelectedObject = new LavaMapProperties(m);
} catch ( Exception ex ) { } catch (Exception ex) {
Server.ErrorLog(ex); Server.ErrorLog(ex);
pg_lavaMap.SelectedObject = null; pg_lavaMap.SelectedObject = null;
} }
@ -171,8 +176,8 @@ namespace MCGalaxy.Gui {
void SaveLavaMapSettings() { void SaveLavaMapSettings() {
if (pg_lavaMap.SelectedObject == null) return; if (pg_lavaMap.SelectedObject == null) return;
LavaMapProperties props = (LavaMapProperties)pg_lavaMap.SelectedObject; LavaMapProperties props = (LavaMapProperties)pg_lavaMap.SelectedObject;
Server.lava.SaveMapSettings(props.m); Server.lava.SaveMapSettings(props.m);
} }
private void lsBtnEndVote_Click(object sender, EventArgs e) { private void lsBtnEndVote_Click(object sender, EventArgs e) {

View File

@ -27,7 +27,6 @@ using MCGalaxy.Util;
namespace MCGalaxy.Gui { namespace MCGalaxy.Gui {
public partial class PropertyWindow : Form { public partial class PropertyWindow : Form {
string lsLoadedMap = "";
ZombieProperties zsSettings = new ZombieProperties(); ZombieProperties zsSettings = new ZombieProperties();
LavaProperties lsSettings = new LavaProperties(); LavaProperties lsSettings = new LavaProperties();