Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

vehicles.c

Go to the documentation of this file.
00001 #if defined(macintosh)
00002 #include <types.h>
00003 #include <time.h>
00004 #else
00005 #include <sys/types.h>
00006 #include <sys/time.h>
00007 #endif
00008 #include <stdio.h>
00009 #include <string.h>
00010 #include <stdlib.h>
00011 #include <unistd.h>
00012 #include "merc.h"
00013 #include "interp.h"
00014 #include "recycle.h"
00015 #include "tables.h"
00016 #include "lookup.h"
00017 #include "vehicles.h" // Main header file for vehicles.
00018 #include "olc.h"
00019 #define VEDIT( fun )        bool fun( CHAR_DATA *ch, char *argument )
00020 void update_vehicle (VDATA *veh);
00021 void send_to_room (char*str,unsigned long int vnum);
00022 /* Create new vehicle, allocate memory for it and return pointer to that vehicle.
00023  * NOTE: this does NOT add it to the v_list. It simple creates it's memory location.
00024  * To add it to the linked list, call add_vehicle(vehicle).
00025  *
00026  * Usage: vehicle = new_vehicle(); Where vehicle is a variable declared as a VDATA *
00027  * type.
00028  */
00029 VDATA * new_vehicle()
00030 {
00031     static VDATA vd;
00032     VDATA *vehicle;
00033 
00034     if (v_free == NULL)
00035         vehicle = alloc_perm(sizeof(*vehicle));
00036     else
00037     {
00038         vehicle = v_free;
00039         v_free = v_free->next;
00040     }
00041     *vehicle = vd;
00042     vehicle->room = alloc_perm(sizeof(*vehicle->room));
00043     vehicle->vnum = 0;
00044     vehicle->armor = 0;
00045     vehicle->max_armor = 0;
00046     vehicle->max_riders = 0;
00047     vehicle->path = NULL;
00048     vehicle->terrain = 0;
00049     vehicle->speed = 0;
00050     vehicle->max_speed = 0;
00051     vehicle->type = 0;
00052     vehicle->name = NULL;
00053     vehicle->s_vnum = 0;
00054     vehicle->i_vnum = 0;
00055     vehicle->cur_path_pos = 0;
00056     vehicle->loaded = FALSE;
00057     
00058     return vehicle;
00059 }
00060 
00061 /* Add a vehicle to the vehicle linked list. This does NOT allocate the memory for the
00062  * vehicle. You must do that via new_vehicle.
00063  *
00064  * Usage: add_vehicle(vehicle) where vehicle is an already-created VDATA struct called with
00065  * new_vehicle
00066  */
00067 void add_vehicle(VDATA *vehicle)
00068 {
00069     vehicle->next = v_list;
00070     v_list = vehicle;
00071     logf("Vehicle->path=%s", vehicle->path);
00072     logf("Vehicle->s_vnum=%d", vehicle->s_vnum);
00073     logf("Vehicle->i_vnum=%d", vehicle->i_vnum);
00074     
00075     return;
00076 }
00077 
00078 /* Delete a vehicle from the list. This does NOT delete the vehicle from memory, per-se.
00079  * Why? Because we don't want to disrupt the linked list. Since it will be NULL, no
00080  * use of it will be availble and it'll dissapear upon next copyover/reboot. The save
00081  * code will NOT save a null'd vehicle.
00082  *
00083  * Usage: delete_vehicle(vehicle); where Vehicle is an already allocated vehicle of type
00084  * VDATA struct.
00085  */
00086 
00087 void delete_vehicle(VDATA *vehicle)
00088 {
00089     if (vehicle == NULL)
00090         return; // no vehicle? We won't free it then.
00091 
00092     vehicle->room = NULL;
00093     vehicle->vnum = 0;
00094     
00095     vehicle->armor = 0;
00096     vehicle->max_armor = 0;
00097     vehicle->max_riders = 0;
00098     vehicle->path = NULL;
00099     vehicle->name = NULL;
00100     vehicle->terrain = 0;
00101     vehicle->speed = 0;
00102     vehicle->max_speed = 0;
00103     vehicle->type = 0;
00104     vehicle->s_vnum = 0;
00105     vehicle->i_vnum = 0;
00106     vehicle->cur_path_pos = 0;
00107     vehicle->loaded = FALSE;
00108 
00109     logf("Vehicle freed.");
00110 }
00111 
00112 
00113 
00114 void save_vehicles()
00115 {
00116     FILE *fp;
00117     VDATA *vehicle;
00118     bool first_pass = TRUE;
00119 
00120     if ((fp = fopen(VEHICLE_FILE, "w")) == NULL)
00121     {
00122         logf("Unable to save vehicles!");
00123         return;
00124     }
00125 
00126     for (vehicle=v_list;vehicle;vehicle = vehicle->next)
00127     {
00128         if (vehicle->name == NULL)
00129             continue; // DOn't save it
00130         if (first_pass == FALSE)
00131             fprintf(fp, "\n");
00132         fprintf(fp, "Armor %d\n",vehicle->armor); 
00133         fprintf(fp, "MRiders %d\n",vehicle->max_riders);
00134             fprintf(fp, "Terrain %d\n", vehicle->terrain);
00135         fprintf(fp, "Speed %d\n", vehicle->speed);
00136         fprintf(fp, "MSpeed %d\n", vehicle->max_speed);
00137         fprintf(fp, "Type %d\n", vehicle->type);
00138         fprintf(fp, "Path %s~\n", vehicle->path);
00139         fprintf(fp, "Name %s~\n", vehicle->name);
00140         fprintf(fp, "Vnum %d\n", vehicle->vnum);
00141         fprintf(fp, "SVnum %d", vehicle->s_vnum);
00142         first_pass = FALSE;
00143         
00144     }
00145 
00146     fclose(fp);
00147 }
00148 void load_vehicles()
00149 {
00150     FILE *fp;
00151     char buf[MSL];
00152     VDATA *vehicle;
00153     extern unsigned long int v_count;
00154 
00155     if ((fp = fopen(VEHICLE_FILE, "r")) == NULL)
00156     {
00157         logf("Unable to open vehicle file for reading.");
00158         return;
00159     }
00160     
00161     while (!feof(fp))
00162     {
00163         twiddle();
00164         if (!str_cmp(fread_word(fp), "Armor"))
00165         {
00166             logf("Loading armor");
00167             vehicle = new_vehicle();
00168             vehicle->armor = fread_number(fp);
00169         }
00170         if (!str_cmp(fread_word(fp), "MRiders"))
00171         {
00172             logf("Loading max_riders");
00173             vehicle->max_riders = fread_number(fp);
00174         }
00175         if (!str_cmp(fread_word(fp), "Terrain"))
00176         {
00177             logf("Loading terrain");
00178             vehicle->terrain = fread_number(fp);
00179         }
00180         if (!str_cmp(fread_word(fp), "Speed"))
00181         {
00182             logf("Loading speed");
00183             vehicle->speed = fread_number(fp);
00184         }
00185         if (!str_cmp(fread_word(fp), "MSpeed"))
00186         {
00187             logf("Loading max_speed");
00188             vehicle->max_speed = fread_number(fp);
00189         }
00190         if (!str_cmp(fread_word(fp), "Type"))
00191         {
00192             logf("Loading type");
00193             vehicle->type = fread_number(fp);
00194         }
00195         if (!str_cmp(fread_word(fp), "Path"))
00196         {
00197             logf("Loading path");
00198             vehicle->path = fread_string(fp);
00199         }
00200         if (!str_cmp(fread_word(fp), "Name"))
00201         {
00202             logf("Loading Name");
00203             vehicle->name = fread_string(fp);
00204         }
00205         
00206         if (!str_cmp(fread_word(fp), "Vnum"))
00207         {
00208             logf("Loading vnum");
00209             vehicle->vnum = fread_number(fp);
00210             logf("Saving vehicle");
00211             v_count+=1;
00212             vehicle->room = get_room_index(vehicle->vnum);
00213             
00214         }
00215         if (!str_cmp(fread_word(fp), "SVnum"))
00216         {
00217             logf("Loading start vnums");
00218             vehicle->s_vnum = fread_number(fp);
00219             vehicle->i_vnum = vehicle->s_vnum;
00220             vehicle->loaded = TRUE;
00221             add_vehicle(vehicle);
00222         }
00223         continue;
00224     }
00225     fclose(fp);
00226     send_to_all_copyover("\bDone.\n\r");
00227 
00228         
00229             
00230         
00231 }
00232 
00233         
00234         
00235 void do_show_vehicles(CHAR_DATA *ch, char*argument)
00236 {
00237     char buf[MAX_INPUT_LENGTH];
00238     char pbuf[MSL];
00239     int found=0;
00240     
00241 
00242     VDATA *vehicle;
00243     
00244     
00245 
00246     printf_to_char(ch,"{c%-15s %-5s %-5s %-5s %-5s %-8s %-8s %-7s %-7s %-5s {x\n\r","Name","Vnum","SVnum","IVnum", "Armor", "MRiders", 
00247             "Terrain", "Speed", "MSpeed", "Type");
00248     send_to_char("{c---------------------------------------------------------------------------------------------{x\n\r",ch);
00249 
00250     for (vehicle=v_list;vehicle;vehicle=vehicle->next)
00251     {
00252         if (vehicle->room == NULL)
00253             continue;
00254         colourconv2(pbuf, vehicle->name);
00255         printf_to_char(ch,"%-15.15s %-5d %-5d %-5d %-5d %-8d %-8d %-7d %-7d %-5d\n\r",pbuf,
00256                 vehicle->vnum, vehicle->s_vnum,vehicle->i_vnum,vehicle->armor,vehicle->max_riders,vehicle->terrain,
00257                 vehicle->speed, vehicle->max_speed,vehicle->type);
00258         found++;
00259     }
00260     if (found == 0)
00261         send_to_char("No vehicles found.\n\r",ch);
00262 
00263     return;
00264 }
00265 
00266 void do_board (CHAR_DATA *ch, char * argument)
00267 {
00268     char pbuf[MSL];
00269     VDATA *vehicle;
00270     if (argument[0] == '\0')
00271     {
00272         send_to_char("What do you want to board?\n\r",ch);
00273         return;
00274     }
00275     for (vehicle=v_list;vehicle;vehicle=vehicle->next)
00276     {
00277         if (vehicle->i_vnum != ch->in_room->vnum)
00278         {
00279             send_to_char("I don't see that here.\n\r",ch);
00280             return;
00281         }
00282         colourconv2(pbuf,vehicle->name);
00283         if (!str_prefix(argument, pbuf))
00284         {
00285             printf_to_char(ch,"You board the %s.\n\r", vehicle->name);
00286             char_from_room(ch);
00287             char_to_room(ch, get_room_index(vehicle->vnum));
00288             return;
00289         }
00290     }
00291     send_to_char("You don't see that here.\n\r",ch);
00292     return;
00293 }
00294                 
00295 void do_disembark (CHAR_DATA *ch, char *argument)
00296 {
00297     VDATA *vehicle;
00298 
00299     for (vehicle=v_list;vehicle;vehicle=vehicle->next)
00300     {
00301         if (vehicle->room->area == ch->in_room->area)
00302         {
00303                 
00304             printf_to_char(ch,"You disembark from the %s.\n\r",vehicle->name);
00305             char_from_room(ch);
00306             char_to_room(ch, get_room_index(vehicle->i_vnum));
00307             return;
00308         }
00309     }
00310     send_to_char("You're not ON a vehicle, how can you disembark?\n\r",ch);
00311     
00312     return;
00313 }
00314 
00315 /* Simple function for redit to see if a vehicle is assigned
00316  * to that room or not. */
00317 
00318 int vehicle_here (unsigned long int vnum)
00319 {
00320     VDATA *vehicle;
00321     int vcount=0;
00322 
00323     for (vehicle=v_list;vehicle;vehicle=vehicle->next)
00324     {
00325         if (vehicle->vnum == vnum || vehicle->i_vnum == vnum)
00326             vcount+=1;
00327     }
00328     return vcount;
00329 }
00330 VEDIT (vedit_create)
00331 {
00332     VDATA *vehicle;
00333     vehicle = new_vehicle();
00334     add_vehicle(vehicle);
00335 
00336     ch->desc->pEdit = (void*)vehicle;
00337 
00338     send_to_char("VEdit: Vehicle created.\n\r",ch);
00339     vehicle->name = str_dup(argument);
00340     return;
00341 }
00342 
00343 VEDIT (vedit_show)
00344 {
00345     VDATA *vehicle;
00346     EDIT_VEHICLE (ch, vehicle);
00347 
00348     printf_to_char(ch, "Name      : [{c%s{x]\n\r", vehicle->name);
00349     printf_to_char(ch, "Vnum      : [{c%d{x]\n\r", vehicle->vnum);
00350     printf_to_char(ch, "Start Vnum: [{c%d{x]\n\r", vehicle->s_vnum);
00351     printf_to_char(ch, "Armor     : [{c%d{x]\n\r", vehicle->armor);
00352     printf_to_char(ch, "Max riders: [{c%d{x]\n\r",vehicle->max_riders);
00353     printf_to_char(ch, "Path      : [{c%s{x]\n\r", vehicle->path);
00354     printf_to_char(ch, "Terrain   : [{c%d{x]\n\r",vehicle->terrain);
00355     printf_to_char(ch, "Speed     : [{c%d{x]\n\r", vehicle->speed);
00356     printf_to_char(ch, "Type      : [{c%d{x]\n\r\n\r", vehicle->type);
00357     return;
00358 }
00359 
00360 VEDIT (vedit_name)
00361 {
00362     VDATA *vehicle;
00363     EDIT_VEHICLE(ch, vehicle);
00364 
00365     if (argument[0] == '\0')
00366     {
00367         printf_to_char(ch, "Name is: %s\n\r", vehicle->name);
00368         return;
00369     }
00370     vehicle->name = str_dup(argument);
00371 
00372     printf_to_char(ch, "Name set to: %s\n\r",vehicle->name);
00373     return;
00374 }
00375 
00376 VEDIT (vedit_vnum)
00377 {
00378     VDATA *vehicle;
00379     EDIT_VEHICLE(ch, vehicle);
00380     
00381 
00382     if (argument[0] == '\0' || !is_number(argument))
00383     {
00384         send_to_char("Vedit: Please enter a numeric value. This value must point to an already-created room.\n\r",ch);
00385         return;
00386     }
00387     if (atoi(argument) < 0)
00388     {
00389         send_to_char("Vedit: Vnum must be above zero!\n\r",ch);
00390         return;
00391     }
00392     if (get_room_index(atoi(argument)) == NULL)
00393     {
00394         send_to_char("Vedit: Room not found. Please make sure vnum is an already created room!\n\r",ch);
00395         return;
00396     }
00397     vehicle->vnum = atoi(argument);
00398     send_to_char("Vedit: Vnum set.\n\r",ch);
00399     vehicle->room = get_room_index(atoi(argument));
00400     return;
00401 }
00402 
00403 VEDIT (vedit_svnum)
00404 {
00405     VDATA *vehicle;
00406     EDIT_VEHICLE(ch,vehicle);
00407 
00408     if (argument[0] == '\0' || !is_number(argument))
00409     {
00410         send_to_char("Vedit: Please enter a numerical value. This value must point to an already-created room.\n\r",ch);
00411         return;
00412     }
00413     if (atoi(argument) < 0)
00414     {
00415         send_to_char("VEdit: Start vnum must be above zero!\n\r",ch);
00416         return;
00417     }
00418     if (get_room_index(atoi(argument)) == NULL)
00419     {
00420         send_to_char("Vedit: Room not found. Please make sure this vnum is already created!\n\r",ch);
00421         return;
00422     }
00423     vehicle->s_vnum = atoi(argument);
00424     send_to_char("Vedit: Start vnum set.\n\r",ch);
00425     return;
00426 }
00427 
00428 VEDIT (vedit_armor)
00429 {
00430     VDATA *vehicle;
00431     EDIT_VEHICLE(ch,vehicle);
00432 
00433     if (argument[0] == '\0' || !is_number(argument))
00434     {
00435         send_to_char("Vedit: Armor must be a numeric value.\n\r",ch);
00436         return;
00437     }
00438     
00439     if (atoi(argument) < 0)
00440     {
00441         send_to_char("Vedit: Armor value must be ATLEAST zero.\n\r",ch);
00442         return;
00443     }
00444     vehicle->armor = atoi(argument);
00445     send_to_char("Vedit: Vehicle's armor set.\n\r",ch);
00446 }
00447 
00448 VEDIT (vedit_path)
00449 {
00450     VDATA *vehicle;
00451     EDIT_VEHICLE(ch,vehicle);
00452 
00453     if (argument[0] == '\0')
00454     {
00455         send_to_char("Vedit: Path must contain SOMETHING.\n\r",ch);
00456         return;
00457     }
00458     vehicle->path = str_dup(argument);
00459     send_to_char("Vedit: Vehicle's path set.\n\r",ch);
00460     return;
00461 }
00462 
00463 VEDIT (vedit_terrain)
00464 {
00465     VDATA *vehicle;
00466     EDIT_VEHICLE(ch,vehicle);
00467 
00468     if (argument[0] == '\0' || !is_number(argument))
00469     {
00470         send_to_char("Vedit: Terrain must be a numberic value.\n\r",ch);
00471         return;
00472     }
00473     if (atoi(argument) < 0)
00474     {
00475         send_to_char("Vedit: Value too low. Try something that is NOT lower than zero?\n\r",ch);
00476         return;
00477     }
00478     vehicle->terrain = atoi(argument);
00479     send_to_char("Vedit: Vehicle's terrain set.\n\r",ch);
00480     return;
00481 
00482 }
00483 
00484 VEDIT (vedit_speed)
00485 {
00486     VDATA *vehicle;
00487     EDIT_VEHICLE(ch, vehicle);
00488 
00489     if (argument[0] == '\0' || !is_number(argument))
00490     {
00491         send_to_char("Vedit: Vehicle's speed MUST be a numeric value.\n\r",ch);
00492         return;
00493     }
00494     if (atoi(argument) < 0)
00495     {
00496         send_to_char("Vedit: Value too low.\n\r",ch);
00497         return;
00498     }
00499     vehicle->speed = atoi(argument);
00500     send_to_char("Vedit: Vehicle's speed set.\n\r",ch);
00501     return;
00502 }
00503 
00504 VEDIT (vedit_type)
00505 {
00506     VDATA *vehicle;
00507     EDIT_VEHICLE(ch, vehicle);
00508 
00509     if (argument[0] == '\0' || !is_number(argument))
00510     {
00511         send_to_char("Vedit: Vehicle's type MUST be a numberic value.\n\r",ch);
00512         return;
00513     }
00514     if (atoi(argument)< 0)
00515     {
00516         send_to_char("Vedit: Value too low.\n\r",ch);
00517         return;
00518     }
00519     vehicle->type = atoi(argument);
00520     send_to_char("Vedit: Vehicle's type set.\n\r", ch);
00521     return;
00522 }
00523 
00524 VEDIT (vedit_max_riders)
00525 {
00526     VDATA *vehicle;
00527     EDIT_VEHICLE(ch,vehicle);
00528 
00529     if (argument[0] == '\0' || !is_number(argument))
00530     {
00531         send_to_char("Vedit: Vehicle's max riders MUST be numeric.\n\r",ch);
00532         return;
00533     }
00534     if (atoi(argument) < 0)
00535     {
00536         send_to_char("Vedit: Value too low.\n\r",ch);
00537         return;
00538     }
00539     vehicle->max_riders = atoi(argument);
00540     send_to_char("Vedit: Vehicle's max riders set.\n\r",ch);
00541     return;
00542 }
00543 
00544 VEDIT (vedit_delete)
00545 {
00546     VDATA *vehicle;
00547     EDIT_VEHICLE (ch,vehicle);
00548 
00549     delete_vehicle(vehicle);
00550 
00551     send_to_char("Vedit: Vehicle marked for deletion. It shall dissapear after copyover.\n\r",ch);
00552     return;
00553 }
00554 
00555 
00556 
00557 void update_vehicle (VDATA *veh)
00558 {
00559     char buf[MAX_STRING_LENGTH];
00560     char arg3[MAX_INPUT_LENGTH];
00561     char buf3[MSL];
00562     EXIT_DATA *pexit;
00563     CHAR_DATA *ch;
00564     ROOM_INDEX_DATA *t_room= get_room_index(veh->i_vnum);
00565     OBJ_DATA *obj;
00566     char *pdesc;
00567     int door;
00568     int number, count;
00569     VDATA *vehicle;
00570     DESCRIPTOR_DATA *d;
00571     sprintf(buf, "The %s has arrived.\n\r", veh->name);
00572     send_to_room(buf, veh->i_vnum);
00573 
00574     for (d=descriptor_list;d;d = d->next)
00575     {
00576         
00577         if (d->connected != CON_PLAYING)
00578             return;
00579         
00580         if (d->character->in_room->area != veh->room->area)
00581             return;
00582         ch = d->character;
00583         
00584     
00585 
00586 
00587         if (ch->position < POS_SLEEPING)
00588         {
00589             continue;;
00590         }
00591 
00592 
00593 
00594         if (!IS_NPC (ch)
00595             && !IS_SET (ch->act, PLR_HOLYLIGHT) && room_is_dark (t_room))
00596         {
00597             send_to_char ("It is pitch black ... \n\r", ch);
00598             show_char_to_char (t_room->people, ch);
00599             continue;
00600         }
00601 
00602         count = 0;
00603 
00604         if (time_info.hour > 18 || time_info.hour < 7)
00605         {
00606                 sprintf(buf3, "{D%s {w({rDark{w){x", t_room->name);
00607                 send_to_char(buf3,ch);
00608         }
00609         else
00610         {
00611                 sprintf(buf3, "{c%s{x", t_room->name);
00612                 send_to_char(buf3,ch);
00613         }
00614         if ((IS_IMMORTAL (ch)
00615              && (IS_NPC (ch) || IS_SET (ch->act, PLR_HOLYLIGHT)))
00616              || IS_BUILDER (ch, t_room->area))
00617         {
00618              sprintf (buf, "{r [{RRoom %d{r]{x", t_room->vnum);
00619              send_to_char (buf, ch);
00620         }
00621 
00622         send_to_char ("\n\r", ch);
00623     
00624         send_to_char ("  ", ch);
00625         send_to_char ("{S", ch);
00626         if (time_info.hour >= 18 || time_info.hour < 6)
00627         {
00628                 printf_to_char(ch, "%s{x", t_room->night_description);
00629         }
00630         else
00631         {
00632                 send_to_char (t_room->description, ch);
00633         }
00634         send_to_char ("{x", ch);
00635         
00636 
00637         for (vehicle=v_list;vehicle;vehicle=vehicle->next)
00638         {
00639                 if (vehicle->i_vnum == t_room->vnum)
00640                         printf_to_char(ch,"    The %s is here.\n\r", vehicle->name);
00641         }
00642 
00643         show_list_to_char (t_room->contents, ch, FALSE, FALSE);
00644         show_char_to_char (t_room->people, ch);
00645     
00646  
00647 
00648 
00649         for (obj = t_room->contents; obj != NULL; obj = obj->next_content)
00650         {
00651             if (can_see_obj (ch, obj))
00652             {
00653                 pdesc = get_extra_descr (arg3, obj->extra_descr);
00654                 if (pdesc != NULL)
00655                     if (++count == number)
00656                     {
00657                         send_to_char (pdesc, ch);
00658                         break;
00659                     }
00660 
00661                 pdesc = get_extra_descr (arg3, obj->pIndexData->extra_descr);
00662                 if (pdesc != NULL)
00663                     if (++count == number)
00664                     {
00665                         send_to_char (pdesc, ch);
00666                         break;
00667                     }
00668 
00669                 if (is_name (arg3, obj->name))
00670                     if (++count == number)
00671                     {
00672                         send_to_char (obj->description, ch);
00673                         send_to_char ("\n\r", ch);
00674                         break;
00675                     }
00676             }
00677         }
00678     }
00679 
00680 
00681     return;
00682 }
00683 
00684 
00685 void send_to_room (char*str,unsigned long int vnum)
00686 {
00687     DESCRIPTOR_DATA *d;
00688     ROOM_INDEX_DATA *rdata;
00689     
00690     if (vnum < 0 || (rdata = get_room_index(vnum)) == NULL)
00691         return;
00692     
00693     for (d=descriptor_list;d;d=d->next)
00694     {
00695         if (d->connected != CON_PLAYING)
00696             continue;
00697         if (d->character->in_room->vnum == vnum)
00698         {
00699             send_to_char(str,d->character);
00700             continue;
00701         }
00702     }
00703     return;
00704 }
00705 
00706 
00707 void move_vehicle_npc (VDATA *vehicle)
00708 {
00709     bool returning=FALSE;
00710     char buf[MIL];
00711     ROOM_INDEX_DATA *to_room;
00712     EXIT_DATA *pexit;
00713     ROOM_INDEX_DATA *t_room;
00714     char *const d_d[] = {"North", "South", "East", "West", "Northwest", "Northeast", "Southeast", "Southwest"};
00715     if (vehicle->loaded == FALSE)
00716         return;
00717     if (vehicle->path == NULL || vehicle->path[0] == '\0')
00718     {
00719         bug("Vehicle does not have a path!",0);
00720         return;
00721     }
00722     if (vehicle->cur_path_pos == strlen(vehicle->path))
00723         vehicle->cur_path_pos = 0;
00724 
00725     /*
00726      * n = north
00727      * s = south
00728      * w = west
00729      * e = east
00730      * N = northwest
00731      * E = northeast
00732      * S = southwest
00733      * W = southeast
00734      * 0-9 = wait 'ticks' -- explained later. not coded yet.
00735      */
00736     t_room = get_room_index(vehicle->i_vnum);
00737     if (!returning)
00738     {
00739         switch(vehicle->path[vehicle->cur_path_pos])
00740         {
00741             case 'n':
00742             {
00743                 if ((pexit = t_room->exit[DIR_NORTH]) == NULL ||
00744                         (to_room = pexit->u1.to_room) == NULL)
00745                 {
00746                     bugf("Vehicle's path is incorrect.",0);
00747                     return;
00748                 }
00749                 sprintf(buf, "The %s goes %s\n\r", vehicle->name, d_d[0]);
00750                 send_to_room(buf,vehicle->i_vnum);
00751                 vehicle->i_vnum = to_room->vnum;
00752                 update_vehicle(vehicle);
00753                 //add that later.
00754                 break;
00755             }
00756             case 's':
00757             {
00758                 if ((pexit = t_room->exit[DIR_SOUTH]) == NULL ||
00759                         (to_room = pexit->u1.to_room) == NULL)
00760                 {
00761                     bugf("Vehicle's path is incorrect.",0);
00762                     return;
00763                 }
00764                                 sprintf(buf, "The %s goes %s\n\r", vehicle->name, d_d[1]);
00765                     send_to_room(buf, vehicle->i_vnum);
00766                                 
00767                 vehicle->i_vnum = to_room->vnum;
00768                 update_vehicle(vehicle);                
00769                 break;
00770             }
00771             case 'w':
00772             {
00773                                 if ((pexit = t_room->exit[DIR_WEST]) == NULL ||
00774                                                 (to_room = pexit->u1.to_room) == NULL)
00775                                 {
00776                                         bugf("Vehicle's path is incorrect.",0);
00777                                         return;
00778                                 }
00779                                 sprintf(buf, "The %s goes %s\n\r", vehicle->name, d_d[3]);
00780                     send_to_room(buf,vehicle->i_vnum);
00781                                 
00782                 vehicle->i_vnum = to_room->vnum;
00783                 update_vehicle(vehicle);
00784 
00785                 break;
00786             }
00787             case 'e':
00788             {
00789                                 if ((pexit = t_room->exit[DIR_EAST]) == NULL ||
00790                                                 (to_room = pexit->u1.to_room) == NULL)
00791                                 {
00792                                         bugf("Vehicle's path is incorrect.",0);
00793                                         return;
00794                                 }
00795                                 sprintf(buf, "The %s goes %s\n\r", vehicle->name, d_d[2]);
00796                                 send_to_room(buf,vehicle->i_vnum);
00797                 
00798                                 vehicle->i_vnum = to_room->vnum;
00799                 update_vehicle(vehicle);
00800 
00801                 break;
00802             }
00803             case 'N':
00804             {
00805                                 if ((pexit = t_room->exit[DIR_NORTHWEST]) == NULL ||
00806                                                 (to_room = pexit->u1.to_room) == NULL)
00807                                 {
00808                                         bugf("Vehicle's path is incorrect.",0);
00809                                         return;
00810                                 }
00811                                 sprintf(buf, "The %s goes %s\n\r", vehicle->name, d_d[4]);
00812                             send_to_room(buf,vehicle->i_vnum);
00813                     
00814                                 vehicle->i_vnum = to_room->vnum;
00815                 update_vehicle(vehicle);
00816 
00817                 break;
00818             }
00819             case 'E':
00820             {
00821                                 if ((pexit = t_room->exit[DIR_NORTHEAST]) == NULL ||
00822                                                 (to_room = pexit->u1.to_room) == NULL)
00823                                 {
00824                                         bugf("Vehicle's path is incorrect.",0);
00825                                         return;
00826                                 }
00827                                 sprintf(buf, "The %s goes %s\n\r", vehicle->name, d_d[5]);
00828                                 send_to_room(buf,vehicle->i_vnum);
00829                 
00830                                 vehicle->i_vnum = to_room->vnum;
00831                 update_vehicle(vehicle);
00832 
00833                 break;
00834             }
00835             case 'S':
00836             {
00837                                 if ((pexit = t_room->exit[DIR_SOUTHWEST]) == NULL ||
00838                                                 (to_room = pexit->u1.to_room) == NULL)
00839                                 {
00840                                         bugf("Vehicle's path is incorrect.",0);
00841                                         return;
00842                                 }
00843                                 sprintf(buf, "The %s goes %s\n\r", vehicle->name, d_d[7]);
00844                                 send_to_room(buf,vehicle->i_vnum);
00845                 
00846                                 vehicle->i_vnum = to_room->vnum;
00847                 update_vehicle(vehicle);
00848                 
00849 
00850                 break;
00851             }
00852             case 'W':
00853             {
00854                                 if ((pexit = t_room->exit[DIR_SOUTHEAST]) == NULL ||
00855                                                 (to_room = pexit->u1.to_room) == NULL)
00856                                 {
00857                                         bugf("Vehicle's path is incorrect.",0);
00858                                         return;
00859                                 }
00860                                 sprintf(buf, "The %s goes %s\n\r", vehicle->name, d_d[6]);
00861                                 send_to_room(buf,vehicle->i_vnum);
00862                 
00863                                 vehicle->i_vnum = to_room->vnum;
00864                 update_vehicle(vehicle);
00865 
00866                 break;
00867             }
00868             default:break;
00869         }
00870     }
00871     vehicle->cur_path_pos++;
00872     return;
00873 }
00874             
00875     

Generated on Thu Jan 13 21:48:14 2005 for Beyond the Shadows by  doxygen 1.4.0