[Newbie][Code] Stupid time problem

From: Dust (dustlos@hotmail.com)
Date: 04/30/01


Hello all, I've added in a new thing to zedit for only executing the command
during the night, day, or anytime. This works pretty much fine, however the
function I use to determine if its alright to load a mob (or to get rid of
it if they are flagged with day_only or night_only) isn't always working
properly. I've been puzzled by this for some time and need a fresh idea
here... Generally in this function, if it returns 0 that means it isnt the
right time and it wouldn't do the command.


int time_alright(int argument)
{
 int x = 0;
 if (argument < 1 || argument > 2)
    return 1;
 else if ( (argument == 1) ) {
    if (time_info.hours > TIME_DAWN && time_info.hours < TIME_DUSK) {
      sprintf(buf, "Argument %s allowed at time_hour %d.",
name_statuses[argument], time_info.hours);
      mudlog(buf, CMP, LVL_IMMORT, FALSE);
      x = 1;
    }
    else if (time_info.hours < TIME_DUSK && time_info.hours > TIME_DAWN) {
      sprintf(buf, "Argument %s allowed at time_hour %d.",
name_statuses[argument], time_info.hours);
      mudlog(buf, CMP, LVL_IMMORT, FALSE);
      x = 1;
    }
    else
      x = 0;
 }
 else if ( (argument == 2) ) {
    if (time_info.hours < TIME_DAWN) {
      sprintf(buf, "Argument %s allowed at time_hour %d.",
name_statuses[argument], time_info.hours);
      mudlog(buf, CMP, LVL_IMMORT, FALSE);
      x = 1;
    }
    else if (time_info.hours > TIME_DUSK) {
      sprintf(buf, "Argument %s allowed at time_hour %d.",
name_statuses[argument], time_info.hours);
      mudlog(buf, CMP, LVL_IMMORT, FALSE);
      x = 1;
    }
    else
      x = 0;
 }
 else
    x = 1;
 return (x);
}

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST