(mult, player_coms): Command `mult' is disabled since 4.0.0 ('96), and
its code is obviously not in working order. Remove. (minmult, maxmult, configkeys): Unused configuration parameters, remove. (tradedesc): Remove code related to mult that had no effect. (multread, commread, commwrite, commamt, commset, multset, commprice): Dangerous, because code bypasses ef_read() & friends, remove. (diss): Commodity cleanup uses the above, remove. Command is disabled and unlikely to work anyway.
This commit is contained in:
parent
30cb9e2a83
commit
0c19d70c74
13 changed files with 4 additions and 356 deletions
|
@ -142,7 +142,6 @@ int mobq(void);
|
||||||
int mobupdate(void);
|
int mobupdate(void);
|
||||||
int morale(void);
|
int morale(void);
|
||||||
int move(void);
|
int move(void);
|
||||||
int mult(void);
|
|
||||||
int multifire(void);
|
int multifire(void);
|
||||||
int name(void);
|
int name(void);
|
||||||
int nati(void);
|
int nati(void);
|
||||||
|
|
|
@ -148,14 +148,6 @@ extern double tfactfire(natid cn, double mult);
|
||||||
extern double techfact(int level, double mult);
|
extern double techfact(int level, double mult);
|
||||||
extern double techfactfire(int level, double mult);
|
extern double techfactfire(int level, double mult);
|
||||||
extern double reltech(int level1, int level2, double mult);
|
extern double reltech(int level1, int level2, double mult);
|
||||||
/* src/lib/subs/comsub.c */
|
|
||||||
extern double multread(natid, natid);
|
|
||||||
extern int commread(void);
|
|
||||||
extern int commwrite(void);
|
|
||||||
extern int commamt(natid, int, float *);
|
|
||||||
extern void commset(natid, int, int);
|
|
||||||
extern void multset(natid, float);
|
|
||||||
extern void commprice(int, float *);
|
|
||||||
|
|
||||||
extern s_char *cname(natid n);
|
extern s_char *cname(natid n);
|
||||||
extern s_char *relatename(struct natstr *np, natid other);
|
extern s_char *relatename(struct natstr *np, natid other);
|
||||||
|
|
|
@ -187,8 +187,6 @@ extern double fallout_spread;
|
||||||
extern float drnuke_const;
|
extern float drnuke_const;
|
||||||
extern int MARK_DELAY;
|
extern int MARK_DELAY;
|
||||||
extern int TRADE_DELAY;
|
extern int TRADE_DELAY;
|
||||||
extern double maxmult;
|
|
||||||
extern double minmult;
|
|
||||||
extern double buytax;
|
extern double buytax;
|
||||||
extern double tradetax;
|
extern double tradetax;
|
||||||
extern int trade_1_dist;
|
extern int trade_1_dist;
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
.TH Command MULT
|
|
||||||
.NA mult "Set price multipliers of goods"
|
|
||||||
.LV Expert
|
|
||||||
.SY "mult <CNUM/CNAME> <NUMBER>"
|
|
||||||
The mult command allows a nation to set price multipliers
|
|
||||||
of the goods they are selling.
|
|
||||||
.sp
|
|
||||||
The <CNUM/CNAME> argument is the number or name of the nation
|
|
||||||
for which you want to reset the multiplier, and <NUMBER> is
|
|
||||||
the new multiplier (a floating-point number). If no
|
|
||||||
arguments are given, you are prompted for them. A carriage return
|
|
||||||
or incorrect nation at this prompt allows the changing
|
|
||||||
of all the price multipliers.
|
|
||||||
.sp
|
|
||||||
For example, if one nation is a \*Qnice\*U nation,
|
|
||||||
and another is particularly unfriendly,
|
|
||||||
the price multiplier for the nice one might be 0.75,
|
|
||||||
while the \*Qnasty\*U nation might have one around 5.
|
|
||||||
.s1
|
|
||||||
The price multiplier affects the price of a nation's goods
|
|
||||||
to other nations.
|
|
||||||
Final item price is determined by multiplying the price
|
|
||||||
of the item at the time of the sale by the individual price multiplier
|
|
||||||
for the nation buying the item.
|
|
||||||
You cannot have a price multiplier below 0.05.
|
|
||||||
.s1
|
|
||||||
Typical output looks like:
|
|
||||||
.EX mult
|
|
||||||
.NF
|
|
||||||
for which country? bar
|
|
||||||
bar ( 1.000) : 3.00
|
|
||||||
.FI
|
|
||||||
.s1
|
|
||||||
.EX mult
|
|
||||||
.NF
|
|
||||||
for which country?
|
|
||||||
Editing nation price multipliers...
|
|
||||||
MGM (1.00) :
|
|
||||||
hodedo (2.55) : 100
|
|
||||||
bar (1.00) : ^C
|
|
||||||
Aborted
|
|
||||||
.FI
|
|
||||||
.s1
|
|
||||||
The second editing session left unchanged all price multipliers except the
|
|
||||||
one for country \*Qhodedo\*U, which was set to 100.
|
|
||||||
.s1
|
|
||||||
.SA "buy, sell, Obsolete"
|
|
|
@ -42,7 +42,7 @@ OBJS = acce.o add.o anti.o arm.o army.o assa.o atta.o bdes.o best.o boar.o \
|
||||||
expl.o fina.o flash.o flee.o fly.o foll.o forc.o fort.o fuel.o give.o \
|
expl.o fina.o flash.o flee.o fly.o foll.o forc.o fort.o fuel.o give.o \
|
||||||
grin.o hard.o head.o hidd.o improve.o info.o land.o laun.o lboard.o \
|
grin.o hard.o head.o hidd.o improve.o info.o land.o laun.o lboard.o \
|
||||||
ldump.o ledg.o leve.o load.o look.o lost.o lstat.o lten.o map.o \
|
ldump.o ledg.o leve.o load.o look.o lost.o lstat.o lten.o map.o \
|
||||||
marc.o mark.o mfir.o mine.o miss.o mobq.o mobu.o mora.o move.o mult.o \
|
marc.o mark.o mfir.o mine.o miss.o mobq.o mobu.o mora.o move.o \
|
||||||
name.o nati.o navi.o ndump.o new.o newe.o news.o nuke.o offe.o offs.o \
|
name.o nati.o navi.o ndump.o new.o newe.o news.o nuke.o offe.o offs.o \
|
||||||
orde.o orig.o para.o path.o payo.o pboa.o pdump.o plan.o play.o \
|
orde.o orig.o para.o path.o payo.o pboa.o pdump.o plan.o play.o \
|
||||||
powe.o prod.o pstat.o rada.o rang.o rea.o real.o reco.o reje.o rela.o \
|
powe.o prod.o pstat.o rada.o rang.o rea.o real.o reco.o reje.o rela.o \
|
||||||
|
@ -64,7 +64,7 @@ NTOBJS = acce.obj add.obj anti.obj arm.obj army.obj assa.obj atta.obj \
|
||||||
land.obj laun.obj lboard.obj ldump.obj ledg.obj leve.obj load.obj \
|
land.obj laun.obj lboard.obj ldump.obj ledg.obj leve.obj load.obj \
|
||||||
look.obj lost.obj lstat.obj lten.obj map.obj marc.obj mark.obj \
|
look.obj lost.obj lstat.obj lten.obj map.obj marc.obj mark.obj \
|
||||||
mfir.obj mine.obj miss.obj mobq.obj mobu.obj mora.obj move.obj \
|
mfir.obj mine.obj miss.obj mobq.obj mobu.obj mora.obj move.obj \
|
||||||
mult.obj name.obj nati.obj navi.obj ndump.obj new.obj newe.obj \
|
name.obj nati.obj navi.obj ndump.obj new.obj newe.obj \
|
||||||
news.obj nuke.obj offe.obj offs.obj orde.obj orig.obj para.obj \
|
news.obj nuke.obj offe.obj offs.obj orde.obj orig.obj para.obj \
|
||||||
path.obj payo.obj pboa.obj pdump.obj plan.obj play.obj powe.obj \
|
path.obj payo.obj pboa.obj pdump.obj plan.obj play.obj powe.obj \
|
||||||
prod.obj pstat.obj rada.obj rang.obj rea.obj real.obj reco.obj \
|
prod.obj pstat.obj rada.obj rang.obj rea.obj real.obj reco.obj \
|
||||||
|
|
|
@ -236,13 +236,6 @@ diss(void)
|
||||||
loan.l_status = LS_FREE;
|
loan.l_status = LS_FREE;
|
||||||
putloan(ni.cur, &loan);
|
putloan(ni.cur, &loan);
|
||||||
}
|
}
|
||||||
/* clean up commodity and trade for this nation. */
|
|
||||||
commread();
|
|
||||||
for (n = 1; n < I_MAX + 1; n++) {
|
|
||||||
val = commamt(player->cnum, n, &dummy);
|
|
||||||
commset(player->cnum, n, -val);
|
|
||||||
}
|
|
||||||
commwrite();
|
|
||||||
snxtitem_all(&ni, EF_TRADE);
|
snxtitem_all(&ni, EF_TRADE);
|
||||||
while (nxtitem(&ni, (s_char *)&trade)) {
|
while (nxtitem(&ni, (s_char *)&trade)) {
|
||||||
if (trade.trd_unitid >= 0 && trade.trd_owner == player->cnum) {
|
if (trade.trd_unitid >= 0 && trade.trd_owner == player->cnum) {
|
||||||
|
|
|
@ -1,114 +0,0 @@
|
||||||
/*
|
|
||||||
* Empire - A multi-player, client/server Internet based war game.
|
|
||||||
* Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
|
|
||||||
* Ken Stevens, Steve McClure
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* ---
|
|
||||||
*
|
|
||||||
* See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
|
|
||||||
* related information and legal notices. It is expected that any future
|
|
||||||
* projects/authors will amend these files as needed.
|
|
||||||
*
|
|
||||||
* ---
|
|
||||||
*
|
|
||||||
* mult.c: Set per-nation list of price multipliers
|
|
||||||
*
|
|
||||||
* Known contributors to this file:
|
|
||||||
* Dave Pare, 1986
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "misc.h"
|
|
||||||
#include "player.h"
|
|
||||||
#include "var.h"
|
|
||||||
#include "nat.h"
|
|
||||||
#include "file.h"
|
|
||||||
#include "xy.h"
|
|
||||||
#include "nsc.h"
|
|
||||||
#include "commands.h"
|
|
||||||
#include "optlist.h"
|
|
||||||
#include <math.h> /* bailey@math-cs.kent.edu */
|
|
||||||
|
|
||||||
static void multsingle(natid us, natid them, struct natstr *natp);
|
|
||||||
|
|
||||||
int
|
|
||||||
mult(void)
|
|
||||||
{
|
|
||||||
struct nstr_item ni;
|
|
||||||
struct natstr nat;
|
|
||||||
int nats;
|
|
||||||
|
|
||||||
if (!opt_MARKET) {
|
|
||||||
pr("The market is disabled.\n");
|
|
||||||
return RET_FAIL;
|
|
||||||
}
|
|
||||||
pr("The mult command is no longer used.\n");
|
|
||||||
if (!snxtitem(&ni, EF_NATION, player->argp[1]))
|
|
||||||
return RET_SYN;
|
|
||||||
if (commread() < 0) {
|
|
||||||
pr("Unable to read commodity file; get help!\n");
|
|
||||||
return RET_SYS;
|
|
||||||
}
|
|
||||||
nats = 0;
|
|
||||||
while (!player->aborted && nxtitem(&ni, (s_char *)&nat)) {
|
|
||||||
if ((nat.nat_stat & STAT_NORM) == 0)
|
|
||||||
continue;
|
|
||||||
multsingle(player->cnum, (natid)ni.cur, &nat);
|
|
||||||
nats++;
|
|
||||||
}
|
|
||||||
pr("%d nation multipliers changed\n", nats);
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the multipler for a single country.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
multsingle(natid us, natid them, struct natstr *natp)
|
|
||||||
{
|
|
||||||
double price;
|
|
||||||
s_char *p;
|
|
||||||
s_char prompt[128];
|
|
||||||
s_char buf[1024];
|
|
||||||
|
|
||||||
sprintf(prompt, "%s (%7.3f) : ", natp->nat_cnam, multread(us, them));
|
|
||||||
p = getstarg(player->argp[2], prompt, buf);
|
|
||||||
if (p == 0 || *p == 0)
|
|
||||||
return;
|
|
||||||
if ((price = atof(p)) == 0.0)
|
|
||||||
return;
|
|
||||||
#if defined(HUGE)
|
|
||||||
if ((price == HUGE) || (price > 1000000.0)) /* Inf causes overflow. */
|
|
||||||
#else
|
|
||||||
if (price > 1000000.0)
|
|
||||||
#endif
|
|
||||||
price = 1000000.0; /* bailey@math-cs.kent.edu */
|
|
||||||
/*
|
|
||||||
* no free lunches!
|
|
||||||
*/
|
|
||||||
if (price <= minmult)
|
|
||||||
price = minmult;
|
|
||||||
if (price >= maxmult)
|
|
||||||
price = maxmult;
|
|
||||||
if (commread() < 0) {
|
|
||||||
pr("Unable to re-read commodity file; get help!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
multset(them, price);
|
|
||||||
if (commwrite() < 0) {
|
|
||||||
pr("Unable to write out commodity file; get help!\n");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -299,10 +299,6 @@ struct keymatch configkeys[] = {
|
||||||
"Number of seconds commodities stay on the market for bidding"},
|
"Number of seconds commodities stay on the market for bidding"},
|
||||||
{"TRADE_DELAY", intset, (caddr_t)&TRADE_DELAY, 0,
|
{"TRADE_DELAY", intset, (caddr_t)&TRADE_DELAY, 0,
|
||||||
"Number of seconds ships, planes, and units stay on the market for bidding"},
|
"Number of seconds ships, planes, and units stay on the market for bidding"},
|
||||||
{"maxmult", doubleset, (caddr_t)&maxmult, 0,
|
|
||||||
"Maximum trade multiple (used for mult command)"},
|
|
||||||
{"minmult", doubleset, (caddr_t)&minmult, 0,
|
|
||||||
"Minimum trade multiple (used for mult command)"},
|
|
||||||
{"buytax", doubleset, (caddr_t)&buytax, 0,
|
{"buytax", doubleset, (caddr_t)&buytax, 0,
|
||||||
"Tax (in percentage points) charged to the buyer on market purchases"},
|
"Tax (in percentage points) charged to the buyer on market purchases"},
|
||||||
{"tradetax", doubleset, (caddr_t)&tradetax, 0,
|
{"tradetax", doubleset, (caddr_t)&tradetax, 0,
|
||||||
|
|
|
@ -156,8 +156,6 @@ double bankint = 0.25; /* bank interest rate (dt * bars) */
|
||||||
charged (price paid * buytax).
|
charged (price paid * buytax).
|
||||||
Not perfect, but it works. :) */
|
Not perfect, but it works. :) */
|
||||||
|
|
||||||
double minmult = 0.5; /* minimum trade mulitple */
|
|
||||||
double maxmult = 10.0; /* maximum trade multiple */
|
|
||||||
double tradetax = 0.99; /* Tax charged on trade */
|
double tradetax = 0.99; /* Tax charged on trade */
|
||||||
double buytax = 1.0; /* Tax charged on market purchases */
|
double buytax = 1.0; /* Tax charged on market purchases */
|
||||||
int startmob = 127; /* Sanctuary starting mobility */
|
int startmob = 127; /* Sanctuary starting mobility */
|
||||||
|
|
|
@ -162,7 +162,6 @@ struct cmndstr player_coms[] = {
|
||||||
{"move <c|m|s|g|p|i|o|b|f|r|u> <SECT> <NUM> <PATH|DESTINATION>", 1,
|
{"move <c|m|s|g|p|i|o|b|f|r|u> <SECT> <NUM> <PATH|DESTINATION>", 1,
|
||||||
move, C_MOD, NORM + CAP},
|
move, C_MOD, NORM + CAP},
|
||||||
{"mquota <SHIPS> <value>", 2, mobq, C_MOD, NORM + CAP},
|
{"mquota <SHIPS> <value>", 2, mobq, C_MOD, NORM + CAP},
|
||||||
{"mult [COUNTRY]", 1, mult, C_MOD, GOD},
|
|
||||||
{"name <SHIPS> <NAME>", 0, name, C_MOD, NORM},
|
{"name <SHIPS> <NAME>", 0, name, C_MOD, NORM},
|
||||||
{"nation", 0, nati, 0, VIS},
|
{"nation", 0, nati, 0, VIS},
|
||||||
{"navigate <SHIPS> <PATH|DESTINATION>", 1, navi, C_MOD, NORM + CAP},
|
{"navigate <SHIPS> <PATH|DESTINATION>", 1, navi, C_MOD, NORM + CAP},
|
||||||
|
|
|
@ -36,7 +36,7 @@ LIB = $(SRCDIR)/lib/libsubs.a
|
||||||
NTLIB = $(SRCDIR)\lib\libsubs.lib
|
NTLIB = $(SRCDIR)\lib\libsubs.lib
|
||||||
|
|
||||||
OBJS = aircombat.o askyn.o aswplnsubs.o attsub.o bigmap.o border.o bsanct.o \
|
OBJS = aircombat.o askyn.o aswplnsubs.o attsub.o bigmap.o border.o bsanct.o \
|
||||||
caploss.o chkmoney.o cnumb.o comsub.o control.o detonate.o disloan.o \
|
caploss.o chkmoney.o cnumb.o control.o detonate.o disloan.o \
|
||||||
distrea.o fileinit.o fortdef.o getbit.o getele.o land.o landgun.o \
|
distrea.o fileinit.o fortdef.o getbit.o getele.o land.o landgun.o \
|
||||||
list.o lndsub.o lostsub.o mission.o move.o mslsub.o mtch.o natarg.o \
|
list.o lndsub.o lostsub.o mission.o move.o mslsub.o mtch.o natarg.o \
|
||||||
neigh.o nreport.o nstr.o nuke.o nxtitem.o nxtsct.o paths.o plane.o \
|
neigh.o nreport.o nstr.o nuke.o nxtitem.o nxtsct.o paths.o plane.o \
|
||||||
|
@ -45,7 +45,7 @@ OBJS = aircombat.o askyn.o aswplnsubs.o attsub.o bigmap.o border.o bsanct.o \
|
||||||
takeover.o trdsub.o trechk.o whatitem.o wu.o
|
takeover.o trdsub.o trechk.o whatitem.o wu.o
|
||||||
|
|
||||||
NTOBJS = aircombat.obj askyn.obj aswplnsubs.obj attsub.obj bigmap.obj \
|
NTOBJS = aircombat.obj askyn.obj aswplnsubs.obj attsub.obj bigmap.obj \
|
||||||
border.obj bsanct.obj caploss.obj chkmoney.obj cnumb.obj comsub.obj \
|
border.obj bsanct.obj caploss.obj chkmoney.obj cnumb.obj \
|
||||||
control.obj detonate.obj disloan.obj distrea.obj fileinit.obj fortdef.obj \
|
control.obj detonate.obj disloan.obj distrea.obj fileinit.obj fortdef.obj \
|
||||||
getbit.obj getele.obj land.obj landgun.obj list.obj lndsub.obj \
|
getbit.obj getele.obj land.obj landgun.obj list.obj lndsub.obj \
|
||||||
lostsub.obj mission.obj move.obj mslsub.obj mtch.obj natarg.obj neigh.obj \
|
lostsub.obj mission.obj move.obj mslsub.obj mtch.obj natarg.obj neigh.obj \
|
||||||
|
|
|
@ -1,164 +0,0 @@
|
||||||
/*
|
|
||||||
* Empire - A multi-player, client/server Internet based war game.
|
|
||||||
* Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
|
|
||||||
* Ken Stevens, Steve McClure
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
* ---
|
|
||||||
*
|
|
||||||
* See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
|
|
||||||
* related information and legal notices. It is expected that any future
|
|
||||||
* projects/authors will amend these files as needed.
|
|
||||||
*
|
|
||||||
* ---
|
|
||||||
*
|
|
||||||
* comsub.c: Commodity read/write stuff
|
|
||||||
*
|
|
||||||
* Known contributors to this file:
|
|
||||||
* Dave Pare, 1986
|
|
||||||
* Steve McClure, 1998
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "misc.h"
|
|
||||||
#include "player.h"
|
|
||||||
#include "var.h"
|
|
||||||
#include "nat.h"
|
|
||||||
#include "prototypes.h"
|
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
#include <sys/uio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int commf;
|
|
||||||
|
|
||||||
int c_comm[MAXNOC][I_MAX + 1];
|
|
||||||
float c_price[MAXNOC][I_MAX + 1];
|
|
||||||
float c_mult[MAXNOC][MAXNOC];
|
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
static struct iovec commvec[3] = {
|
|
||||||
{(caddr_t)c_comm, sizeof(c_comm)}
|
|
||||||
,
|
|
||||||
{(caddr_t)c_price, sizeof(c_price)}
|
|
||||||
,
|
|
||||||
{(caddr_t)c_mult, sizeof(c_mult)}
|
|
||||||
};
|
|
||||||
static int nvec = sizeof(commvec) / sizeof(struct iovec);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* comm file is the list of "deity commodities"
|
|
||||||
* lying around. Perhaps a better way of doing this
|
|
||||||
* might be at each update seeing what is on sale,
|
|
||||||
* then buying it, then distributing things amongst the
|
|
||||||
* people wanting the items.
|
|
||||||
*
|
|
||||||
* Of course that would be a gigantic pain...
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
|
||||||
commread(void)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
|
|
||||||
(void)lseek(commf, (off_t) 0, 0);
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
if ((n = readv(commf, commvec, nvec)) !=
|
|
||||||
sizeof(c_comm) + sizeof(c_price) + sizeof(c_mult)) {
|
|
||||||
logerror("commread: readv returns %d", n);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if ((n = read(commf, c_comm, sizeof(c_comm))) != sizeof(c_comm)) {
|
|
||||||
logerror("commread: read returns %d, not %d", n, sizeof(c_comm));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ((n = read(commf, c_price, sizeof(c_price))) != sizeof(c_price)) {
|
|
||||||
logerror("commread: read returns %d, not %d", n, sizeof(c_price));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ((n = read(commf, c_mult, sizeof(c_mult))) != sizeof(c_mult)) {
|
|
||||||
logerror("commread: read returns %d, not %d", n, sizeof(c_mult));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
commwrite(void)
|
|
||||||
{
|
|
||||||
#if defined(_WIN32)
|
|
||||||
int n;
|
|
||||||
#endif
|
|
||||||
(void)lseek(commf, (off_t) 0, 0);
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
if (writev(commf, commvec, nvec) !=
|
|
||||||
sizeof(c_comm) + sizeof(c_price) + sizeof(c_mult)) {
|
|
||||||
logerror("commwrite: writev failed");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if ((n = write(commf, c_comm, sizeof(c_comm))) != sizeof(c_comm)) {
|
|
||||||
logerror("commwrite: write returns %d, not %d", n, sizeof(c_comm));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ((n = write(commf, c_price, sizeof(c_price))) != sizeof(c_price)) {
|
|
||||||
logerror("commwrite: write returns %d, not %d", n,
|
|
||||||
sizeof(c_price));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ((n = write(commf, c_mult, sizeof(c_mult))) != sizeof(c_mult)) {
|
|
||||||
logerror("commwrite: write returns %d, not %d", n, sizeof(c_mult));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* returns amount of commodity, and price to the user
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
commamt(natid trader, int product, float *priceval)
|
|
||||||
{
|
|
||||||
*priceval = c_price[trader][product] * c_mult[trader][player->cnum];
|
|
||||||
return c_comm[trader][product];
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
commset(natid trader, int product, int amt)
|
|
||||||
{
|
|
||||||
c_comm[trader][product] += amt;
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
multread(natid trader, natid tradee)
|
|
||||||
{
|
|
||||||
return c_mult[trader][tradee];
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
multset(natid tradee, float newmult)
|
|
||||||
{
|
|
||||||
c_mult[player->cnum][tradee] = newmult;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
commprice(int product, float *newprice)
|
|
||||||
{
|
|
||||||
c_price[player->cnum][product] = *newprice;
|
|
||||||
}
|
|
|
@ -104,7 +104,6 @@ int
|
||||||
trade_desc(struct trdstr *tp, union trdgenstr *tgp)
|
trade_desc(struct trdstr *tp, union trdgenstr *tgp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
float price;
|
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
struct nukstr *np;
|
struct nukstr *np;
|
||||||
struct shpstr *sp;
|
struct shpstr *sp;
|
||||||
|
@ -116,7 +115,6 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
|
||||||
struct plnstr plane;
|
struct plnstr plane;
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
|
|
||||||
price = multread(tp->trd_owner, player->cnum) * tp->trd_price;
|
|
||||||
switch (tp->trd_type) {
|
switch (tp->trd_type) {
|
||||||
case EF_NUKE:
|
case EF_NUKE:
|
||||||
np = &tgp->nuk;
|
np = &tgp->nuk;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue