Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Working hotboot for native windows.
Working hotboot for native windows.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| OniPanda
(16 posts) Bio
|
Date
| Fri 17 Sep 2004 08:44 AM (UTC) Amended on Fri 17 Sep 2004 09:21 AM (UTC) by OniPanda
|
Message
| I put in samson's hotboot code, and I got it to compile with only 2 warnings. Since I'm running windows 2000 and Visual C++ 6, I had to comment out unistd.h, wait.h, and dirent.h. With those commented out it gives me these warnings:
Compiling...
hotboot.c
C:\smaug\src\hotboot.c(701) : warning C4013: 'execl' undefined; assuming extern returning int
C:\smaug\src\hotboot.c(765) : warning C4013: 'close' undefined; assuming extern returning int
Both of these are in other header file, execl is in process.h, and close is in io.h. Other than those warning, it compiles and runs, but when i go to hotboot, it just shuts the server down, however, when using my startup bat file (based on some files it plain reboots, reboots using the fresh compiled exe, or shuts down the server completely) it gives me this:
Fri Sep 17 03:43:42 2004 :: Hotboot initiated by Buu.
Fri Sep 17 03:43:42 2004 :: Preserving world state....
Fri Sep 17 03:43:42 2004 :: Saving player files and connection states....
Fri Sep 17 03:43:42 2004 :: Executing hotboot....
SMAUG 1.4a
Working directory now C:\smaug\area
Fri Sep 17 03:43:42 2004 :: Booting Database
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Fri Sep 17 03:43:42 2004 :: [*****] BOOT: ---------------------[ Boot Log ]-----
---------------
Fri Sep 17 03:43:42 2004 :: Loading commands
Fri Sep 17 03:43:42 2004 :: Loading sysdata configuration...
Fri Sep 17 03:43:42 2004 :: Loading socials
Fri Sep 17 03:43:42 2004 :: Loading skill table
Fri Sep 17 03:43:42 2004 :: Sorting skill table...
Fri Sep 17 03:43:42 2004 :: Remapping slots to sns
Fri Sep 17 03:43:42 2004 :: Loading classes
Fri Sep 17 03:43:42 2004 :: Loading races
Fri Sep 17 03:43:42 2004 :: Loading herb table
Fri Sep 17 03:43:42 2004 :: Loading tongues
Fri Sep 17 03:43:42 2004 :: Making wizlist
Fri Sep 17 03:43:42 2004 :: Initializing request pipe
Fri Sep 17 03:43:42 2004 :: Initializing random number generator
Fri Sep 17 03:43:42 2004 :: Setting time and weather
Fri Sep 17 03:43:42 2004 :: Assigning gsn's
Fri Sep 17 03:43:42 2004 :: Reading in plane file...
../system/planes.dat: No such file or directory
Fri Sep 17 03:43:42 2004 :: [*****] BUG: load_planes: can't open plane file for
read.
Fri Sep 17 03:43:42 2004 :: Reading in area files...
SMAUG 1.4a
Usage is :-
SMAUG - runs as a service, or stand-alone
SMAUG /run - runs stand-alone
SMAUG /start - starts this service
SMAUG /stop - stops this service
SMAUG /install - installs this service
SMAUG /remove - removes (un-installs) this service
SMAUG /status - displays the status of this service
SMAUG /help - displays this information
(help.are)
(imc-help.are)
(ice-help.are)
gods.are : Rooms: 1200 - 1201 Objs: 1200 - 1200 Mobs: 1200 - 1200
limbo.are : Rooms: 1 - 43 Objs: 2 - 99 Mobs: 1 - 99
...
which it just reboots the server. The only thing that comes to mind is either execl is different in process.h from unistd, or I'm using it wrong (Most likely the latter). My current execl statement is this:
execl( EXE_FILE, "smaug-test", buf, "hotboot", buf2, buf6, (char *)NULL );
(#define EXE_FILE "../smaug-test" )
What am I overlooking? | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 18 Sep 2004 03:36 AM (UTC) |
Message
| In the execl line I think you need to add /run as an argument to the program. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| OniPanda
(16 posts) Bio
|
Date
| Reply #2 on Sat 18 Sep 2004 08:01 AM (UTC) Amended on Sat 18 Sep 2004 08:09 AM (UTC) by OniPanda
|
Message
| In messing with the execl statement, I stumbled across a possible reason why it's not working. First off, the main fuction in service.c makes it only check for the / commands, and ignore any other start command, including changing the port at command line. ("smaug /run 4000" wouldn't run, "smaug 4000" wouldn't run, "smaug /run" would) which hotboot needs more parameters.
I also found another problem, after taking the command line options, it runs worker_thread. Worker_thread doesn't take the command line parameters from main, and it resets argc and argv to null, and passes them to main_thread in comm.c, which is the varibles hotboot uses. So since they're set to null, it fails to hotboot.
I'm making a wee bit of progress here, I'll keep yall posted. | Top |
|
Posted by
| OniPanda
(16 posts) Bio
|
Date
| Reply #3 on Sat 18 Sep 2004 08:41 AM (UTC) |
Message
| IT WORKS ><!
I've gotten it to successfully hotboot on a native windows server. There's still some minor things that need to be done to make sure the server doesn't crash on a non hotboot, make it have a seperate exe to copyover to, ect.
Once I'm done with making sure I've gotten everything working right, I'll write out the needed changes. | Top |
|
Posted by
| Marowi
(65 posts) Bio
|
Date
| Reply #4 on Sun 19 Sep 2004 02:35 AM (UTC) |
Message
| What exactly have did you make it do? Startup from one exe and hotboot from another? I was able to do this, but it only allows for one hotboot. I left it a while and tried moving to a linux server (but my startup script isn't working - the thread's somewhere around).
Keep us/me posted on this, because I'm interested in what it can do.
Thanks | Top |
|
Posted by
| OniPanda
(16 posts) Bio
|
Date
| Reply #5 on Sun 19 Sep 2004 09:23 AM (UTC) |
Message
| Yes, with windows, you can't compile while the server is running, so you can't update the exe used to hotboot to while it's running. The simple solution is to make it hotboot a different exe than the one you compile, but therein lies the problem. The exe has to be renamed before it hotboots which is where I'm having a problem. For one, I need to fix it to not try to boot two copies when I hotboot using my startup bat file, but that's fairly minor comparatively.
The question is, is there any function that can rename a file, or anyway to rename the file through the code? | Top |
|
Posted by
| OniPanda
(16 posts) Bio
|
Date
| Reply #6 on Sun 19 Sep 2004 10:56 AM (UTC) Amended on Sun 19 Sep 2004 11:00 AM (UTC) by OniPanda
|
Message
| Ok, this is what I did to get it to work. I'm using 1.4a_W32 to be exact. Here's what needs to be changed in order for it to work:
Ok, first, service.c needs to be changed.
First off, you need to change the declaration of worker_thread from
VOID worker_thread(VOID *notused);
to
VOID worker_thread( int argc, char **argv);
This was the main problem, main takes the command line paramaters, but the way they had it, didn't actually pass it on to the mainthread in comm.c where the game is actually booted, which was why it wasn't working.
Then, you need to change
if ((argc == 2) &&
((*argv[1] == '-') || (*argv[1] == '/') || (*argv[1] == '\'))
)
{
to
if ( (argc >= 2) && ( (*argv[1] == '-') || (*argv[1] == '/') || (*argv[1] == '\') ) )
{
That's required so it won't keep popping up the uses statement, because hotboot passes several paramaters to the new copy of the program, and with the old way it wouldn't run the new copy because you gave it more than 1 command line paramater.
After that, the actual worker_thread function needs to be changed from
static VOID worker_thread(VOID *notused)
{
to
static VOID worker_thread( int argc, char **argv)
{
So that pass on the commandline parameters.
Then, delete the lines
and
char * argv [2] = {"", ""} ;
Worker_thread was setting up empty commandline paramaters and that's what was getting passed to mainthread in comm.c
Lastly for service.c, you need to change all 3 calls to worker_thread from
to
worker_thread ( argc, argv );
Now for comm.c, in mainthread, go to
/*
* Get the port number.
*/
port = 4000;
if ( argc > 1 )
{
if ( !is_number( argv[1] ) )
{
fprintf( stderr, "Usage: %s [port #]\n", argv[0] );
exit( 1 );
}
else if ( ( port = atoi( argv[1] ) ) <= 1024 )
{
fprintf( stderr, "Port number must be above 1024.\n" );
exit( 1 );
}
if (argv[2] && argv[2][0])
{
fCopyOver = TRUE;
control = atoi( argv[3] );
control2 = atoi( argv[4] );
conclient = atoi( argv[5] );
conjava = atoi( argv[6] );
}
else
fCopyOver = FALSE;
}
and change it to
/*
* Get the port number.
*/
port = 4000;
if ( argc > 1 )
{
if ( argv[2] ) // Have to make sure there's actually a second argument
{
if ( !is_number( argv[2] ) ) // This is assuming the port will be the second arguement
{ // Will take additional coding to make the / commands and
fprintf( stderr, "Usage: %s [port #]\n", argv[0] ); // a commandline port
exit( 1 );
}
else if ( ( port = atoi( argv[2] ) ) <= 1024 )
{
fprintf( stderr, "Port number must be above 1024.\n" );
exit( 1 );
}
}
if ( argv[2] && argv[3] ) // Makes sure there's a port and a descriptor
{
fCopyOver = TRUE;
control = atoi( argv[3] );
control2 = atoi( argv[4] );
conclient = atoi( argv[5] );
conjava = atoi( argv[6] );
}
else
fCopyOver = FALSE;
}
Not only will that fix the problem with it not taking a command line port in windows, that also what makes the hotboot work. So with those changes, hotboot should work, but I might be forgetting something (it's 6 am and I'm sleepy, soooo), so if that doesn't work, post here and I'll see if I'm forgetting something. | Top |
|
Posted by
| Marowi
(65 posts) Bio
|
Date
| Reply #7 on Sun 19 Sep 2004 11:23 AM (UTC) |
Message
| I run off a highly-modified SWR and I've moved to a linux server (but am having problems with my startup script). If you get it so you can compile and run to and from a few different executable, please let me know. I was thinking about having an int stored in system.dat and increment the makefile exe each time. For example, it runs from "smaug%d".
Anyway, please be sure to let me/us know what happens in the end. | Top |
|
Posted by
| OniPanda
(16 posts) Bio
|
Date
| Reply #8 on Sat 25 Sep 2004 03:17 AM (UTC) Amended on Sat 25 Sep 2004 04:32 AM (UTC) by OniPanda
|
Message
| After some research, I found a nice little function that's in stdio.h, rename.
rename looks like this:
int rename( const char *oldname, const char *newname );
It returns 0 if it successfully renames. So I modified my code to this:
rename_result = rename( EXE_ORIG, EXE_FILE );
if ( rename_result != 0 )
{
rename( EXE_ORIG, EXE_FILE_ALT );
execl( EXE_FILE_ALT, "smaug", "/run", buf, buf2, (char *)NULL );
}
else
execl( EXE_FILE, "smaug", "/run", buf, buf2, (char *)NULL );
The way this works, I have the compiler output it to smaug-test.exe [EXE_ORIG], and rename it to smaug-cp.exe [EXE_FILE] and runs it. If it fails to rename the first time (assuming it fails to rename because it's in use), then it renames to smaug-cp-alt.exe [EXE_FILE_ALT], and runs that one instead.
It copies over correctly, and uses the right file, but now I just need to find a way to remove the one it's not using after it copies over.
EDIT: As soon as I hit the post button, I find the remove function, also in stdio.h which looks like:
int remove( const char *path );
and returns 0 if successful, -1 if not. | Top |
|
Posted by
| Asean Novari
USA (82 posts) Bio
|
Date
| Reply #9 on Thu 24 Feb 2005 10:06 PM (UTC) |
Message
| I would appreciate some assistance with making this system work with windows xp, cygwin *(compiled not run), swr1fuss
normal hotboot dosent work anymore so i must revert to this method..
* It was compiled with cygwin but i run the command window by
accessing swreality.exe from the area folder where a guide
told me to place it along with cygwin1.dll |
| Top |
|
Posted by
| Greven
Canada (835 posts) Bio
|
Date
| Reply #10 on Fri 25 Feb 2005 12:16 AM (UTC) |
Message
| Well what errors are you getting? If you can't get it to find the right file, or if you can't get it to compile as you want, they have different fixes. |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | Top |
|
Posted by
| OniPanda
(16 posts) Bio
|
Date
| Reply #11 on Fri 25 Feb 2005 03:18 AM (UTC) |
Message
| Not familiar with swr, but if you put up there errors, I may be able to help some. I really didn't change much to make it work, whoever programmed that part of smaug in the first place just did a poor job on the windows part of loading, so I didn't have to alter too much to make it work properly. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
28,754 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top