SWR

Posted by Shadoan on Tue 10 Apr 2001 03:23 PM — 7 posts, 24,676 views.

Canada #0
Hrm ok well I got SWR 1.0 working, fixed the score bug added tractorbeams and openbay/closebay and edited the who list and wizlist colors, YAY for me :P
Well NOW I'm trying to install a ship hailing code, so:
Ship1 hails Ship2: Hello.
Ship2 hails Ship1: Hi, how are you.
But when I try hailing inside the game i get both the:
You sent: Hello
Ship1 sent: Hello
Dunno whats wrong, I'm gonna post the Hailing code right here:


#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include "mud.h"

void do_hale( CHAR_DATA *ch, char *argument )
{
   
   SHIP_DATA *ship;
   SHIP_DATA *ship2 = ship_from_cockpit( ch->in_room->vnum );
   int  count;
   int top_num=15;
   int vnum[top_num];
   DESCRIPTOR_DATA *i;
   CHAR_DATA *och;
   char buf[MAX_STRING_LENGTH];
   char buf1[MAX_STRING_LENGTH];
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   argument = one_argument( argument, arg1 );
   strcpy(arg2,argument);
   if (arg1[0] == '\0' || arg2[0] == '\0')
   {
   	send_to_char ("Syntax: Hail <ship> <message>\n\r", ch);
   	return;
   }
   
   ship = get_ship( arg1 );
   send_to_char ("\n\r", ch);
   if (!ship)
   {
     send_to_char ("No Such Ship!\n\r", ch);
     return;
   }
   if (!ship2)
   {
   	send_to_char("But your not in a cockpit!\n\r", ch);
   	return;
   }
   sprintf (buf, "&R(&BHAIL&R) &G&W%s sent: %s\n\r", ship2->name, arg2);
   sprintf (buf1, "&R(&BHAIL&R) &G&WYou Send: %s\n\r", arg2);
   send_to_char(buf1, ch);
   sprintf (buf1, "&g%s adjusts some settings on the comm system and says something", ch->name, arg2);
   act( AT_GREEN, buf1,  ch, NULL, NULL, TO_NOTVICT );
   vnum[0] = ship->cockpit;
   vnum[1] = ship->pilotseat;
   vnum[2] = ship->gunseat;
   vnum[3] = ship->coseat;
   vnum[4] = ship->navseat;
   vnum[5] = ship->turret1;
   vnum[6] = ship->turret2;
   
 for (i = first_descriptor; i; i = i->next)
  {
    if (!i->connected && i->character)
    {
      och = i->original ? i->original : i->character;	
    }
   for( count=1; count <= top_num; count = count + 1 )
   {
     if (och->in_room->vnum == vnum[count])
     {
     	send_to_char(buf, och);
     	break;
     }
   }
  }
}
Amended on Tue 10 Apr 2001 09:50 PM by Nick Gammon
Canada #1
Oh and the do_hale in the beginning IS suppose dto be spelled hale NOT hail.
Australia Forum Administrator #2
Well, I can see a few problems.



1. You have defined:


int top_num=15;


However you only set up 7 of them:


vnum[0] = ship->cockpit;
vnum[1] = ship->pilotseat;
vnum[2] = ship->gunseat;
vnum[3] = ship->coseat;
vnum[4] = ship->navseat;
vnum[5] = ship->turret1;
vnum[6] = ship->turret2;


That means that in your loop where you send to vnum index 1 to 15, some of them will be undefined, and might be your own vnum.




2. Your loop here is wrong:


for( count=1; count <= top_num; count = count + 1 )


This will send vnum [1] through to vnum [15], however you have only defined 15 of them, so it should be sending from vnum [0] to vnum [14].

So, it should read:


for( count=0; count < top_num; count++)


Saying "count++" is a short-hand way of adding 1 to count, although what you did will work.




3. I would check you aren't sending to yourself, which - all else being OK - would result in the messages you saw. eg.



   if (ship == ship2)
   {
     send_to_char ("You can't hail yourself!\n\r", ch);
     return;
   }

Canada #3
Cool it worx, thx, it wasn't my code btw a friend found it somewhere and sent it to me, I just edited some of it to make it look nicer(2 lines of it to be exact) :). Ok I don't know if you know much about the SWR codebase but I wanted to be able to make MOB ships into squadron and command all of the squadron from inside a deifferent ship. Don't know how that will work.
Oh and I found anice snippet which is SUPPOSED to make flight simulators work on SWR but it was buggy, if you have time can ya look at it? Just tell me if ya want me to post it.
Ok I'll stop flooding you with questions....for now:)
Australia Forum Administrator #4
I don't have a huge amount of free time myself just now, as I am about to start on a new version of MUSHclient with all the extra features people have been asking for.

You can always post the message here in the hope that someone else will answer it. :)
#5
I come here out of lack of no where else to go. I have Windows 98 and I have recently been running SmaugWizard which allows me to run a smaug server for windows(perhaps you've heard about it). Originally it was to help me learn to build for SWR, which was my real passion, and today I found a similar program that runs SWR called StarWarsSmaug. It came with no documentation so I improvised. I downloaded some smaug source and tried placing it in the directory and running it. It didnt work. Then I downloaded the SWR source and tried it. It seemed to work but every time I tried to do something else, like open a mud client, it restarted my computer. I come to you asking if you know where I could find some documentation on the subject, or whether you can help fix my problem with the mysterious restartings.
Australia Forum Administrator #6
Putting source in the directory won't do much, it needs to be compiled.

I did an executable version of SWR SMAUG which is available from the downloads area, above, it is intended to be loaded on top of a standard SMAUG download (also available from the same place).

It shouldn't restart the PC, unless there is a program bug.

I don't know of any documentation, I did the conversion for someone, but they didn't supply a huge amount of documentation about how to use it, so I don't really know.