maddy_ wrote:but each signal can only have one outgoing link
This could be improved easily. Just forbid creating cycles.
Don't modify MSVC project files manually. List all new files in
./source.list and then use
./projects/generate.vbs to generate project files.
saveload/logic_signals_sl.cpp wrote:struct TempStorage ...
Try harder when naming things.
command.cpp wrote:DEF_CMD(CmdProgramLogicSignal, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_PROGRAM_LOGIC_SIGNAL
Perhaps this command should be of type CMDT_OTHER_MANAGEMENT to allow reprogramming signals while paused.
logic_signals_program.cpp wrote:for (SignalReference *sref = this->linked_signals.Begin(); sref != this->linked_signals.End(); sref++)
{
...
Coding style - remove newline before opening brace.
logic_signals.cpp wrote:try { return _signal_program_list.at(GetSignalReference(tile, track)); } catch (...) { return NULL; }
...
try { return _signal_link_list.at(GetSignalReference(tile, track)); } catch (...) { return NULL; }
Don't use exceptions to implement logic. It's not an exceptional situation when an item is not in the container. Use
std::find instead.
logic_signals.h wrote:#define OPPOSITE_SIGNAL_STATE(state) ((state) == SIGNAL_STATE_RED ? SIGNAL_STATE_GREEN : SIGNAL_STATE_RED)
...
#define MAX_LOGIC_SIGNAL_RECURSIONS 5
Avoid macros. Use a
static inline function and a
static const variable instead.
logic_signals_cmd.cpp wrote:if (CheckTileOwnership(tile).Failed()) return_cmd_error(STR_ERROR_OWNED_BY);
It should be
Code: Select all
CommandCost ret = CheckTileOwnership(tile);
if (ret.Failed()) return ret;
logic_signals_gui.cpp wrote:if (IsWidgetLowered(WID_PROGSIG_ADD_LINK))
SetObjectToPlaceWnd(SPR_CURSOR_TRANSMITTER, PAL_NONE, HT_RECT, this);
else
ResetObjectToPlace();
Coding style - surround if/else sections with braces.
logic_signal_program.cpp
logic_signals_cmd.cpp
logic_signals.cpp
logic_signals_gui.cpp
logic_signals.h
Perhaps you should use existing files to put the code in:
signal_type.h,
signal_func.h,
signal.cpp,
signal_gui.cpp,
rail_cmd.cpp - they seem to be a good place for your code.