home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / alt / games / gb / 1380 < prev    next >
Encoding:
Internet Message Format  |  1992-12-25  |  7.7 KB

  1. Path: sparky!uunet!cs.utexas.edu!gateway
  2. From: deragon@JETHRO.CS.NYU.EDU (John Deragon)
  3. Newsgroups: alt.games.gb
  4. Subject: patches for bid()
  5. Date: 25 Dec 1992 03:25:21 -0600
  6. Organization: UTexas Mail-to-News Gateway
  7. Lines: 278
  8. Sender: daemon@cs.utexas.edu
  9. Message-ID: <9212250923.AA22881@JETHRO.CS.NYU.EDU>
  10. NNTP-Posting-Host: cs.utexas.edu
  11.  
  12.  
  13.     The following patch fixes two bugs in the bid function of GB5.2.
  14.  
  15.   o Checks to see if the bid and shipping costs exceed your current funds.
  16.     (before it only checked for the bid > money not (bid + ship) > money)
  17.  
  18.   o Checks to see if you have outstanding bids and deducts that amount from
  19.     your available funds.  (to prevent a player from bidding on all the lots
  20.     when he only has the money to pay for some of them)
  21.  
  22.     I highly suggest installing this patch, as the latter of the two bugs 
  23.     can cause core dumps.
  24.  
  25.     Seeker
  26.  
  27.  
  28. -------- build.diffs created on Fri Dec 25 03:16:29 EST 1992 ----------
  29. -------- on machine tensha.dev.rockcoast.com by johnd -----------------
  30.  
  31. *** /work/GB5.2/build.c    Fri Nov 27 14:02:57 1992
  32. --- build.c    Fri Dec 25 03:06:35 1992
  33. ***************
  34. *** 1747,1760 ****
  35.       deductAPs(Playernum, Governor, APcount, snum, 0);
  36.   }
  37.   
  38. ! void bid(int Playernum, int Governor, int APcount)
  39.   {
  40.       racetype *Race;
  41.       planettype *p;
  42.       commodtype *c;
  43.       shiptype *s;
  44.       char commod;
  45.       int i, item, bid0, lot, shipping, ok=0, sh;
  46.       int minbid;
  47.       double dist, rate;
  48.       int snum, pnum;
  49. --- 1747,1763 ----
  50.       deductAPs(Playernum, Governor, APcount, snum, 0);
  51.   }
  52.   
  53. ! void
  54. ! bid(int Playernum, int Governor, int APcount)
  55.   {
  56.       racetype *Race;
  57.       planettype *p;
  58.       commodtype *c;
  59. +     commodtype *cc;
  60.       shiptype *s;
  61.       char commod;
  62.       int i, item, bid0, lot, shipping, ok=0, sh;
  63. +     int u, shipcost = 0, money_owed = 0;
  64.       int minbid;
  65.       double dist, rate;
  66.       int snum, pnum;
  67. ***************
  68. *** 1825,1831 ****
  69.           return;
  70.       }
  71.       getplanet(&p, snum, pnum);
  72.       if(p->slaved_to && p->slaved_to!=Playernum) {
  73.           sprintf(buf, "This planet is enslaved to player %d.\n", p->slaved_to);
  74.           notify(Playernum, Governor, buf);
  75. --- 1828,1836 ----
  76.           return;
  77.       }
  78.       getplanet(&p, snum, pnum);
  79. !     /*
  80. !      * Cant bid from an enslaved planet 
  81. !      */
  82.       if(p->slaved_to && p->slaved_to!=Playernum) {
  83.           sprintf(buf, "This planet is enslaved to player %d.\n", p->slaved_to);
  84.           notify(Playernum, Governor, buf);
  85. ***************
  86. *** 1832,1859 ****
  87.           free(p);
  88.           return;
  89.       }
  90. ! /* check to see if there is an undamaged gov center or space port here */
  91.       sh = p->ships;
  92. !     while(sh && !ok) {
  93. !     (void)getship(&s, sh);
  94. !     if(s->alive && (s->owner==Playernum) && !s->damage &&
  95. !        Shipdata[s->type][ABIL_PORT]) ok = 1;
  96. !     sh = s->nextship;
  97. !     free(s);
  98.       }
  99.       if(!ok) {
  100. !     notify(Playernum, Governor, "You don't have an undamaged space port or government center here.\n");
  101. !     free(p);
  102. !     return;
  103.       }
  104.   
  105.       lot = atoi(args[1]);
  106.       bid0 = atoi(args[2]);
  107.       if((lot<=0) || lot>Numcommods()) {
  108.           notify(Playernum, Governor, "Illegal lot number.\n");
  109.           free(p);
  110.           return;
  111.       }
  112.       getcommod(&c, lot);
  113.       if(!c->owner) {
  114.           notify(Playernum, Governor, "No such lot for sale.\n");
  115. --- 1837,1875 ----
  116.           free(p);
  117.           return;
  118.       }
  119. !     /*
  120. !      * check to see if there is an undamaged gov center 
  121. !      * or space port here 
  122. !      */
  123.       sh = p->ships;
  124. !     while (sh && !ok) {
  125. !         (void)getship(&s, sh);
  126. !         if (s->alive && (s->owner==Playernum) && !s->damage &&
  127. !            Shipdata[s->type][ABIL_PORT]) 
  128. !                 ok = 1;
  129. !         sh = s->nextship;
  130. !         free(s);
  131.       }
  132.       if(!ok) {
  133. !         notify(Playernum, Governor,
  134. !          "You don't have an undamaged space port or government center here.\n");
  135. !         free(p);
  136. !         return;
  137.       }
  138.   
  139.       lot = atoi(args[1]);
  140.       bid0 = atoi(args[2]);
  141.       if((lot<=0) || lot>Numcommods()) {
  142.           notify(Playernum, Governor, "Illegal lot number.\n");
  143.           free(p);
  144.           return;
  145.       }
  146. +     /* 
  147. +      * What the HELL does this do?! 
  148. +      */
  149.       getcommod(&c, lot);
  150.       if(!c->owner) {
  151.           notify(Playernum, Governor, "No such lot for sale.\n");
  152. ***************
  153. *** 1861,1866 ****
  154. --- 1877,1883 ----
  155.           free(c);
  156.           return;
  157.       }
  158. + /*    
  159.       if (c->owner == Playernum &&
  160.           (c->star_from != Dir[Playernum-1][c->governor].snum ||
  161.            c->planet_from != Dir[Playernum-1][c->governor].pnum)) {
  162. ***************
  163. *** 1869,1876 ****
  164.           free(c);
  165.           return;
  166.       }
  167.       minbid = (int)((double)c->bid*(1.0+UP_BID));
  168. !     if(bid0 < minbid) {
  169.           sprintf(buf, "You have to bid more than %d.\n", minbid);
  170.           notify(Playernum, Governor, buf);
  171.           free(p);
  172. --- 1886,1894 ----
  173.           free(c);
  174.           return;
  175.       }
  176. + */
  177.       minbid = (int)((double)c->bid*(1.0+UP_BID));
  178. !     if(bid0 <= minbid) {
  179.           sprintf(buf, "You have to bid more than %d.\n", minbid);
  180.           notify(Playernum, Governor, buf);
  181.           free(p);
  182. ***************
  183. *** 1877,1882 ****
  184. --- 1895,1904 ----
  185.           free(c);
  186.           return;
  187.       }
  188. +     /* 
  189. +      * Don't allow guests to screw things up 
  190. +      */
  191.       Race = races[Playernum-1];
  192.       if(Race->Guest) {
  193.           notify(Playernum, Governor, "Guest races cannot bid.\n");
  194. ***************
  195. *** 1884,1889 ****
  196. --- 1906,1914 ----
  197.           free(c);
  198.           return;
  199.       }
  200. +     /*
  201. +       * Make sure they have the bucks 
  202. +      */
  203.       if(bid0 > Race->governor[Governor].money) {
  204.           notify(Playernum, Governor, "Sorry, no buying on credit allowed.\n");
  205.           free(p);
  206. ***************
  207. *** 1890,1906 ****
  208.           free(c);
  209.           return;
  210.       }
  211. ! /* notify the previous bidder that he was just outbidded */
  212.       if(c->bidder) {
  213. !         sprintf(buf, "The bid on lot #%d (%d %s) has been upped to %d by %s [%d].\n", lot, c->amount, Commod[c->type], bid0, Race->name, Playernum);
  214.           notify((int)c->bidder, (int)c->bidder_gov, buf);
  215.       }
  216.       c->bid = bid0;
  217.       c->bidder = Playernum;
  218.       c->bidder_gov = Governor;
  219.       c->star_to = snum;
  220.       c->planet_to = pnum;
  221. !     shipping = shipping_cost((int)c->star_to, (int)c->star_from, &dist, (int)c->bid);
  222.   
  223.       sprintf(buf, "There will be an additional %d charged to you for shipping costs.\n", shipping);
  224.       notify(Playernum, Governor, buf);
  225. --- 1915,1973 ----
  226.           free(c);
  227.           return;
  228.       }
  229. !     /* 
  230. !      * Make sure we check to see if we have enough for shipping costs 
  231. !      * as well.    --JPD--
  232. !      */
  233. !     shipcost = shipping_cost((int)c->star_to, (int)c->star_from, 
  234. !                 &dist, (int)c->bid);
  235. !     if ((bid0 + shipcost) > Race->governor[Governor].money) {
  236. !       sprintf(buf, "The bid (%d) + shipping costs (%d) exceed your money (%d)\n",     
  237. !         bid0, shipcost, Race->governor[Governor].money);
  238. !         notify(Playernum, Governor, buf);
  239. !         free(p);
  240. !         free(c);
  241. !         return;
  242. !     }
  243. !     /* 
  244. !      * Also make sure they have not bid on other things and trying to use 
  245. !      * money earmarked for other lots --JPD--
  246. !      */
  247. !     for (u = 1; u <= Numcommods(); u++) {
  248. !         getcommod(&cc, u);
  249. !             if (cc->bidder == Playernum)
  250. !                 money_owed += cc->bid;
  251. !     }
  252. !     free(cc);
  253. !     
  254. !     if (((bid0 + shipcost) + money_owed) > Race->governor[Governor].money) {
  255. !         notify(Playernum, Governor, "All your money is used in bids already!\n");
  256. !         free(p);
  257. !         free(c);
  258. !         return;
  259. !     }
  260. !     /* 
  261. !      * They passed the credit check, notify the previous bidder 
  262. !      * that he was just outbidded 
  263. !      */
  264.       if(c->bidder) {
  265. !       sprintf(buf, "The bid on lot #%d (%d %s) has been upped to %d by %s [%d].\n", lot, c->amount, Commod[c->type], bid0, Race->name, Playernum);
  266.           notify((int)c->bidder, (int)c->bidder_gov, buf);
  267.       }
  268. +     /* 
  269. +      * Set the commod structs to the new values 
  270. +      */
  271.       c->bid = bid0;
  272.       c->bidder = Playernum;
  273.       c->bidder_gov = Governor;
  274.       c->star_to = snum;
  275.       c->planet_to = pnum;
  276. !     shipping = shipcost;
  277.   
  278.       sprintf(buf, "There will be an additional %d charged to you for shipping costs.\n", shipping);
  279.       notify(Playernum, Governor, buf);
  280.