Skip to content

Commit

Permalink
Remove AList usage from all orders
Browse files Browse the repository at this point in the history
This modifies all orders to no longer be ALists.  Also moves
them to be shared_ptr rather than using raw pointers with
new/delete.

In most cases, I chose to use std::vector for the list of orders
but in some (two) cases I chose std::list since there was a need
to insert at the head.  Choosing vector over list is preferred in
general as it has better speed, but it makes inserting at the head
harder.
  • Loading branch information
jt-traub committed Oct 7, 2024
1 parent 1c281ff commit 56fcbeb
Show file tree
Hide file tree
Showing 11 changed files with 575 additions and 800 deletions.
14 changes: 7 additions & 7 deletions faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ Faction::Faction()
{
exists = 1;
name = 0;

for (auto &ft : *FactionTypes) {
type[ft] = 1;
}

lastchange = -6;
address = 0;
password = 0;
Expand All @@ -129,7 +129,7 @@ Faction::Faction(int n)
{
exists = 1;
num = n;

for (auto &ft : *FactionTypes) {
type[ft] = 1;
}
Expand Down Expand Up @@ -211,7 +211,7 @@ void Faction::Readin(istream& f)
name = new AString(tmp);
AString *temp = name->stripnumber();
SetName(temp);

f >> ws >> tmp;
address = new AString(tmp);
f >> ws >> tmp;
Expand Down Expand Up @@ -675,10 +675,10 @@ int Faction::CanSee(ARegion* r, Unit* u, int practice)
// penalty of 2 to stealth if assassinating and 1 if stealing
// TODO: not sure about the reasoning behind the IMPROVED_AMTS part
int stealpenalty = 0;
if (Globals->HARDER_ASSASSINATION && u->stealorders){
if (u->stealorders->type == O_STEAL) {
if (Globals->HARDER_ASSASSINATION && u->stealthorders){
if (u->stealthorders->type == O_STEAL) {
stealpenalty = 1;
} else if (u->stealorders->type == O_ASSASSINATE) {
} else if (u->stealthorders->type == O_ASSASSINATE) {
if (Globals->IMPROVED_AMTS){
stealpenalty = 1;
} else {
Expand Down
8 changes: 4 additions & 4 deletions game.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class Game
void WriteTimesArticle(AString);

void DoExchangeOrders();
void DoExchangeOrder(ARegion *, Unit *, ExchangeOrder *);
void DoExchangeOrder(ARegion *r, Unit *u, std::shared_ptr<ExchangeOrder> o);

//
// Faction limit functions.
Expand All @@ -444,12 +444,12 @@ class Game
// The DoGiveOrder returns 0 normally, or 1 if no more GIVE orders
// should be allowed
//
int DoGiveOrder(ARegion *, Unit *, GiveOrder *);
int DoGiveOrder(ARegion *r, Unit *u, std::shared_ptr<GiveOrder> o);
//
// The DoWithdrawOrder returns 0 normally, or 1 if no more WITHDRAW
// orders should be allowed
//
int DoWithdrawOrder(ARegion *, Unit *, WithdrawOrder *);
int DoWithdrawOrder(ARegion *r, Unit *u, std::shared_ptr<WithdrawOrder> o);

//
// These are game specific, and can be found in extra.cpp
Expand Down Expand Up @@ -557,7 +557,7 @@ class Game
void RunSacrificeOrders();
void CollectInterQMTransportItems();
void CheckTransportOrders();
AList *CanSeeSteal(ARegion *, Unit *);
std::vector<std::shared_ptr<Faction>> CanSeeSteal(ARegion *, Unit *);
void Do1Steal(ARegion *, Object *, Unit *);
void Do1Assassinate(ARegion *, Object *, Unit *);
void Do1Annihilate(ARegion *reg);
Expand Down
Loading

0 comments on commit 56fcbeb

Please sign in to comment.