02 Sep, 2010, jurdendurden wrote in the 1st comment:
Votes: 0
I have a builder port. It runs off the backups of the main port. Main runs on 9000, Builder runs on 9005. I want to write something like this:

if (port == BUILDER_PORT)
//every 24 hours reboot to match what's in the backups of the main port.

Any ideas? Or codebases I can look at for example?
02 Sep, 2010, Davion wrote in the 2nd comment:
Votes: 0
Most codebases have a variable somewhere near the main() function called 'port'. Often the arguments passed to the MUD are parsed and used to set the port number. Take a look at ROM in the main() function. It'll be there.
02 Sep, 2010, Zeno wrote in the 3rd comment:
Votes: 0
I use conditional compilation to determine this. #ifdef BUILDERPORT
03 Sep, 2010, jurdendurden wrote in the 4th comment:
Votes: 0
In comm.c, the main function, is explicitly sets the port to 4000…. why is this? Why doesn't it draw from the startup script? Is this why when I run GDB it runs on port 4000 every time? Why don't I have problems connecting to port 9000?
03 Sep, 2010, Kline wrote in the 5th comment:
Votes: 0
Most games set the port explicitly if you do not provide it as an argument when running the game; a default catch-all.
03 Sep, 2010, David Haley wrote in the 6th comment:
Votes: 0
It's probably just initializing it for a default as Kline mentioned, and setting it again later if there were arguments on the command line.
03 Sep, 2010, Kline wrote in the 7th comment:
Votes: 0
FWIW in regards to your GDB issue; try using "run rom <port>" within GDB next time to boot it on a non-default.
03 Sep, 2010, Kaz wrote in the 8th comment:
Votes: 0
Any ideas? Or codebases I can look at for example?

I would say: don't look at the port number. Do you want to have to recompile if your builder port moves? What if you want two builder ports?

Instead, simply tell the game it's a builder port via the command line and have it set some global boolean somewhere.
03 Sep, 2010, Rudha wrote in the 9th comment:
Votes: 0
Or just do it in a variable, that if set, means that a builder port is present, and if not, assumes it is not.

04 Sep, 2010, Sharmair wrote in the 10th comment:
Votes: 0
In the SMAUG derived code I use, the base port is a cset option (ie, it is an in game setting).
If you do supply a port on the command line, it will auto become the base port, or you can
set it in game with the cset command doing a live port switch. If you want to find out what
it is set to, you can use the cset command in game to show it (along with the other system
settings), or offline (or if you just like to work in the shell) look in the system.dat file.