Skip to main content
Topic: Ignore undefined menubar tools by "if", instead of "****ert" (Read 2485 times) previous topic - next topic

Ignore undefined menubar tools by "if", instead of "****ert"

In simumenu.cc, there are 3 ****ert to check tool_count.
But this don't allow to share menuconf file with different patched versions like underfround patches.
This is very annoying for testers and players.

Code: [Select]
				****ert(toolnr<GENERAL_TOOL_COUNT);

****ert(toolnr<SIMPLE_TOOL_COUNT);

****ert(toolnr<DIALOGE_TOOL_COUNT);

I think ignoring undefined tools using "if" syntax instead of ****ert is happy for testers and players. So, we can share the same menuconf with them.

Is this possible to change this ?

Code: [Select]
				if (toolnr<GENERAL_TOOL_COUNT) {
}

if (toolnr<SIMPLE_TOOL_COUNT) {
}

if (toolnr<DIALOGE_TOOL_COUNT) {
}

Re: Ignore undefined menubar tools by "if", instead of "****ert"

Reply #1
But then, a normal player using a wrong version may run into troubles, especially if those tools are then used for other functions. (Such patched versions might also have other entries in simuconf.tab, which are interpreted differently.)

I added them actually to help me to find errors when *I* accidently used too high number ... I am not against, but unsure, if in the long run for unexperienced user this would mean more trouble.

EDIT: put the if in, but print error message.

[patch] Ignore undefined menubar tools by "if", instead of "****ert"

Reply #2
Thank you for considering this.
But unfortunately it causes to crash.

A patch attached.

Code: [Select]
Index: simmenu.cc
===================================================================
--- simmenu.cc (r2344)
+++ simmenu.cc (copy)
@@ -553,7 +553,7 @@
  }
  }
  else {
- dbg->error( "werkzeug_t::init_menu()", "When parsing menuconf.tab: No simple tool %i defined (max %i)!", toolnr, GENERAL_TOOL_COUNT );
+ dbg->error( "werkzeug_t::init_menu()", "When parsing menuconf.tab: No simple tool %i defined (max %i)!", toolnr, SIMPLE_TOOL_COUNT );
  }
  }
  else if(strstr(toolname,"dialog_tool[")) {
@@ -578,7 +578,7 @@
  }
  }
  else {
- dbg->error( "werkzeug_t::init_menu()", "When parsing menuconf.tab: No dialog tool %i defined (max %i)!", toolnr, GENERAL_TOOL_COUNT );
+ dbg->error( "werkzeug_t::init_menu()", "When parsing menuconf.tab: No dialog tool %i defined (max %i)!", toolnr, DIALOGE_TOOL_COUNT );
  }
  }
  else if(strstr(toolname,"toolbar[")) {
@@ -612,7 +612,9 @@
  addtool->default_param = strdup(toolname);
  addtool->command_key = 1;
  }
- toolbar_tool[i]->append(addtool);
+ if(addtool) {
+ toolbar_tool[i]->append(addtool);
+ }
  }
  }
  // sort characters