コード例 #1
0
/* does end of month actions */
void passmonth(char &clearformess,char canseethings)
{
   short oldlaw[LAWNUM];
   memmove(oldlaw,law,sizeof(short)*LAWNUM);
   int l, v, p;

   //TIME ADVANCE
   day=1;
   month++;
   if(month==13)
   {
      month=1;
      year++;
   }

   switch(endgamestate)
   {
   case ENDGAME_NONE:
      if(publicmood(-1)>60)
      {
         endgamestate=ENDGAME_CCS_APPEARANCE;
         attitude[VIEW_CONSERVATIVECRIMESQUAD]=0;
      }
      break;
   case ENDGAME_CCS_APPEARANCE:
      if(publicmood(-1)>80)
         endgamestate=ENDGAME_CCS_ATTACKS;
      break;
   case ENDGAME_CCS_ATTACKS:
      if(publicmood(-1)>90)
         endgamestate=ENDGAME_CCS_SIEGES;
      break;
   case ENDGAME_CCS_SIEGES:
   case ENDGAME_CCS_DEFEATED:
      //if(publicmood(-1)>85&&presparty!=LIBERAL_PARTY)
      //   endgamestate=ENDGAME_MARTIALLAW;
      break;
   }

   //CLEAR RENT EXEMPTIONS
   for(l=0;l<len(location);l++) location[l]->newrental=0;

   //YOUR PAPER AND PUBLIC OPINION AND STUFF
   vector<int> nploc;
   for(l=0;l<len(location);l++)
   {
      if((location[l]->compound_walls & COMPOUND_PRINTINGPRESS)&&
         !location[l]->siege.siege&&
          location[l]->renting!=RENTING_CCS) nploc.push_back(l);
   }

   // Check for game over
   endcheck(END_DEAD);
   dispersalcheck(clearformess);

   int guardianpower=0;
   if(len(nploc)&&!disbanding)
   {
      //DO SPECIAL EDITIONS
      int loottypeindex=choosespecialedition(clearformess);

      if(loottypeindex!=-1)
      {
         guardianpower+=10*len(nploc);
         printnews(loottypeindex,len(nploc));

         if(loottype[loottypeindex]->get_idname()=="LOOT_INTHQDISK"|| //For special edition xml file? -XML
            loottype[loottypeindex]->get_idname()=="LOOT_SECRETDOCUMENTS")
         {
            for(int l=0;l<len(nploc);l++)
               criminalizepool(LAWFLAG_TREASON,-1,nploc[l]);
         }
      }
   }

   int libpower[VIEWNUM]={0};

   //STORIES STALE EVEN IF NOT PRINTED
   for(v=0;v<VIEWNUM;v++)public_interest[v]/=2;

   int conspower=200-attitude[VIEW_AMRADIO]-attitude[VIEW_CABLENEWS];

   //HAVING SLEEPERS
   for(int pl=len(pool)-1;pl>0;pl--)
      if(pool[pl]->alive&&(pool[pl]->flag & CREATUREFLAG_SLEEPER))
         sleepereffect(*pool[pl],clearformess,canseethings,libpower);

   //Manage graffiti
   for(int l=0;l<len(location);l++) // Check each location
   {
      for(int c=len(location[l]->changes)-1;c>=0;c--) // Each change to the map
      {
         if(location[l]->changes[c].flag==SITEBLOCK_GRAFFITI||
            location[l]->changes[c].flag==SITEBLOCK_GRAFFITI_CCS||
            location[l]->changes[c].flag==SITEBLOCK_GRAFFITI_OTHER) // Find changes that refer specifically to graffiti
         {
            int power=0,align=0;

            if(location[l]->changes[c].flag==SITEBLOCK_GRAFFITI) align=1;
            if(location[l]->changes[c].flag==SITEBLOCK_GRAFFITI_CCS) align=-1;

            //Purge graffiti from more secure sites (or from non-secure
            //sites about once every five years), but these will
            //influence people more for the current month
            if(securityable(location[l]->type))
            {
               location[l]->changes.erase(location[l]->changes.begin()+c);
               power=5;
            }
            else
            {
               if(location[l]->renting==RENTING_CCS)
                  location[l]->changes[c].flag=SITEBLOCK_GRAFFITI_CCS; // Convert to CCS tags
               else if(location[l]->renting==RENTING_PERMANENT)
                  location[l]->changes[c].flag=SITEBLOCK_GRAFFITI; // Convert to LCS tags
               else
               {
                  power=1;
                  if(!LCSrandom(10))
                     location[l]->changes[c].flag=SITEBLOCK_GRAFFITI_OTHER; // Convert to other tags
                  if(!LCSrandom(10)&&endgamestate<ENDGAME_CCS_DEFEATED&&endgamestate>0)
                     location[l]->changes[c].flag=SITEBLOCK_GRAFFITI_CCS; // Convert to CCS tags
                  if(!LCSrandom(30))
                     location[l]->changes.erase(location[l]->changes.begin()+c); // Clean up
               }
            }
            if(align==1)
            {
               background_liberal_influence[VIEW_LIBERALCRIMESQUAD]+=power;
               background_liberal_influence[VIEW_CONSERVATIVECRIMESQUAD]+=power;
            }
            else if(align==-1)
            {
               background_liberal_influence[VIEW_LIBERALCRIMESQUAD]-=power;
               background_liberal_influence[VIEW_CONSERVATIVECRIMESQUAD]-=power;
            }
         }
      }
   }

   int mediabalance=0;
   int issuebalance[VIEWNUM-5];
   //int stimulus=0;
   //double cost=0;
   //double tax=0;

   //PUBLIC OPINION NATURAL MOVES
   for(v=0;v<VIEWNUM;v++)
   {
      // Liberal essays add their power to the effect of sleepers
      libpower[v]+=background_liberal_influence[v];
      background_liberal_influence[v]=static_cast<short>(background_liberal_influence[v]*0.66);

      if(v==VIEW_LIBERALCRIMESQUADPOS) continue;
      if(v==VIEW_LIBERALCRIMESQUAD) continue;
      //if(v==VIEW_POLITICALVIOLENCE)
      //{
      //   change_public_opinion(VIEW_POLITICALVIOLENCE,-1,0);
      //   continue;
      //}
      if(v==VIEW_CONSERVATIVECRIMESQUAD) continue;
      if(v!=VIEW_AMRADIO&&v!=VIEW_CABLENEWS)
      {
         issuebalance[v] = libpower[v] - conspower;
         mediabalance += issuebalance[v];

         // Heavy randomization -- balance of power just biases the roll
         int roll = issuebalance[v] + LCSrandom(400)-200;

         // If +/-50 to either side, that side wins the tug-of-war
         if(roll < -50)
            change_public_opinion(v,-1,0);
         else if(roll > 50)
            change_public_opinion(v,1,0);
         else // Else random movement
            change_public_opinion(v,LCSrandom(2)*2-1,0);
      }

      // AM Radio and Cable News popularity slowly shift to reflect public
      // opinion over time -- if left unchecked, their subtle influence
      // on society will become a self-perpetuating Conservative nightmare!
      else if(v==VIEW_AMRADIO||v==VIEW_CABLENEWS)
      {
         if(publicmood(-1)<attitude[v])change_public_opinion(v,-1);
         else change_public_opinion(v,1);
      }
   }

   // Temporary Stalinizing Code (TODO: Implement the Stalinist Comrade Squad for changing public opinion, then remove this)
   if(stalinmode) for(int v=0;v<VIEWNUM-3;v++)
   {
      if(stalinview(v,false)) { if((attitude[v]+=3)>100) attitude[v]=100; }
      else { if(--attitude[v]<0) attitude[v]=0; }
   }
   // End Temporary Stalinizing Code (TODO: Implement the Stalinist Comrade Squad for changing public opinion, then remove this)

   // Seduction monthly experience stipends for those liberals
   // who have been getting it on with their love slaves/masters
   // in the background
   for(int s=0;s<len(pool);s++)
   {
      pool[s]->train(SKILL_SEDUCTION,loveslaves(*pool[s])*5);
      if(pool[s]->flag & CREATUREFLAG_LOVESLAVE)
         pool[s]->train(SKILL_SEDUCTION,5);
   }

   /*******************************************************
   *                 INTELLIGENCE REPORT                  *
   *     ONLY IF SHOWMECHANICS OR SHOWWAIT IS DEFINED     *
   *        EYES ONLY - LCS PROPERTY - TOP SECRET         *
   *******************************************************/
   #if defined(SHOWMECHANICS) || defined(SHOWWAIT)
   if(canseethings)
   {
      music.play(MUSIC_ELECTIONS);
      erase();
      set_color(COLOR_WHITE,COLOR_BLACK,1);
      mvaddstr(0,23,"LCS MONTHLY INTELLIGENCE REPORT");
      mvaddstr(2,27,"CURRENT POLITICAL TRENDS");
      int numviews=(endgamestate>=ENDGAME_CCS_DEFEATED||newscherrybusted<2)?VIEWNUM-1:VIEWNUM;
      for(int v=-1-stalinmode,y=4,x=0,pip;v<numviews;v++)
      {
         if((y-4)*2>=numviews+1+stalinmode) y=4,x=40;
         for(pip=2;pip>=-2;pip--)
         {
            set_alignment_color(pip,true);
            if(pip==2) mvaddchar(y,x+22,'\x11');
            addstr("ÄÄÄ");
            if(pip==-2) addchar('\x10');
         }
         if(v>=0) pip=14-(attitude[v]*14)/100;
         else pip=14-(publicmood(v)*14)/100;
         set_alignment_color((14-pip)/3-2,true);
         mvaddstr(y,x,getview(v,false));
         mvaddchar(y++,x+23+pip,'O');
      }
      set_color(COLOR_GREEN,COLOR_BLACK,1);
      mvaddstr(23,0,"Elite Liberal ");
      set_color(COLOR_WHITE,COLOR_BLACK,0);
      addstr("-  ");
      set_color(COLOR_CYAN,COLOR_BLACK,1);
      addstr("Liberal  ");
      set_color(COLOR_WHITE,COLOR_BLACK,0);
      addstr("-  ");
      set_color(COLOR_YELLOW,COLOR_BLACK,1);
      addstr("moderate  ");
      set_color(COLOR_WHITE,COLOR_BLACK,0);
      addstr("-  ");
      set_color(COLOR_MAGENTA,COLOR_BLACK,1);
      addstr("Conservative  ");
      set_color(COLOR_WHITE,COLOR_BLACK,0);
      addstr("-  ");
      set_color(COLOR_RED,COLOR_BLACK,1);
      addstr("Arch-Conservative");
      set_color(COLOR_WHITE,COLOR_BLACK,0);
      mvaddstr(24,0,"Press any key to reflect on these poll numbers.");
      clearformess=1;

      getkey();
   }
   #endif
   /*******************************************************
   *                                                      *
   *               END INTELLIGENCE REPORT                *
   *                                                      *
   *******************************************************/

   //ELECTIONS
   if(month==11){elections(clearformess,canseethings);clearformess=1;}

   //SUPREME COURT
   if(month==6){supremecourt(clearformess,canseethings);clearformess=1;}

   //CONGRESS
   congress(clearformess,canseethings);clearformess=1;

   //DID YOU WIN?
   if(wincheck())
   {
      liberalagenda(1);
      savehighscore(END_WON);
      reset(savefile_name);
      viewhighscores();
      end_game();
   }

   //CONTROL LONG DISBANDS
   if(disbanding&&year-disbandtime>=50)
   {
      music.play(MUSIC_DEFEAT);
      set_color(COLOR_WHITE,COLOR_BLACK,1);

      erase();
      move(12,10);
      addstr("The Liberal Crime Squad is now just a memory.", gamelog);
      gamelog.newline();

      getkey();

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      erase();
      move(12,12);
      addstr("The last LCS members have all been hunted down.", gamelog);
      gamelog.newline();

      getkey();

      set_color(COLOR_BLACK,COLOR_BLACK,1);
      erase();
      move(12,14);
      addstr("They will never see the utopia they dreamed of...", gamelog);
      gamelog.newline();
      gamelog.nextMessage();

      getkey();

      savehighscore(END_DISBANDLOSS);
      reset(savefile_name);
      viewhighscores();
      end_game();
   }

   //UPDATE THE WORLD IN CASE THE LAWS HAVE CHANGED
   updateworld_laws(law,oldlaw);

   //THE SYSTEM!
   for(p=len(pool)-1;p>=0;p--)
   {
      if(disbanding) break;

      if(!pool[p]->alive) continue;
      if(pool[p]->flag & CREATUREFLAG_SLEEPER) continue;
      if(pool[p]->location==-1) continue;

      if(location[pool[p]->location]->type==SITE_GOVERNMENT_POLICESTATION)
      {
         if(clearformess) erase();
         else makedelimiter();

         if(pool[p]->flag & CREATUREFLAG_MISSING)
         {
            set_color(COLOR_MAGENTA,COLOR_BLACK,1);
            move(8,1);
            addstr("Cops re-polluted ", gamelog);
            addstr(pool[p]->name, gamelog);
            addstr("'s mind with Conservatism!", gamelog);
            gamelog.nextMessage();

            getkey();

            removesquadinfo(*pool[p]);
            delete_and_remove(pool,p);
            continue;
         }
         else if(pool[p]->flag & CREATUREFLAG_ILLEGALALIEN && law[LAW_IMMIGRATION]!=2)
         {
            set_color(COLOR_MAGENTA,COLOR_BLACK,1);
            move(8,1);
            addstr(pool[p]->name, gamelog);
            addstr(" has been shipped out to the INS to face ", gamelog);
            if(law[LAW_IMMIGRATION]==-2 && law[LAW_DEATHPENALTY]==-2)
               addstr("execution.", gamelog);
            else addstr("deportation.", gamelog);
            gamelog.newline();

            getkey();

            removesquadinfo(*pool[p]);
            delete_and_remove(pool,p);
            continue;
         }
         else
         {
            //TRY TO GET RACKETEERING CHARGE
            int copstrength=100;
            if(law[LAW_POLICEBEHAVIOR]==-2) copstrength=200;
            if(law[LAW_POLICEBEHAVIOR]==-1) copstrength=150;
            if(law[LAW_POLICEBEHAVIOR]==1) copstrength=75;
            if(law[LAW_POLICEBEHAVIOR]==2) copstrength=50;

            copstrength=(copstrength*pool[p]->heat)/4;
            if(copstrength>200)copstrength=200;

            //Confession check
            if(LCSrandom(copstrength)>pool[p]->juice  +  pool[p]->get_attribute(ATTRIBUTE_HEART,true)*5  -
                                      pool[p]->get_attribute(ATTRIBUTE_WISDOM,true)*5  +  pool[p]->get_skill(SKILL_PSYCHOLOGY)*5
                                      /*+ pool[p]->get_skill(SKILL_SURVIVAL)*5*/  &&  pool[p]->hireid!=-1)
            {
               int nullify=0;
               int p2=getpoolcreature(pool[p]->hireid);

               if(pool[p2]->alive && (pool[p2]->location==-1 || location[pool[p2]->location]->type!=SITE_GOVERNMENT_PRISON))
               {  //Charge the boss with racketeering!
                  criminalize(*pool[p2],LAWFLAG_RACKETEERING);
                  //Rack up testimonies against the boss in court!
                  pool[p2]->confessions++;
               }
               if(!nullify)
               {  //Issue a raid on this guy's base!
                  if(pool[p]->base>=0)location[pool[p]->base]->heat+=300;

                  set_color(COLOR_WHITE,COLOR_BLACK,1);
                  move(8,1);
                  addstr(pool[p]->name, gamelog);
                  addstr(" has broken under the pressure and ratted you out!", gamelog);
                  gamelog.newline();

                  getkey();

                  set_color(COLOR_WHITE,COLOR_BLACK,1);
                  move(9,1);
                  addstr("The traitor will testify in court, and safehouses may be compromised.", gamelog);
                  gamelog.nextMessage();

                  getkey();

                  removesquadinfo(*pool[p]);

                  delete_and_remove(pool,p);
                  continue; //no trial for this person; skip to next person
               }
               //else continue to trial
            }

            set_color(COLOR_WHITE,COLOR_BLACK,1);
            move(8,1);
            addstr(pool[p]->name, gamelog);
            addstr(" is moved to the courthouse for trial.", gamelog);
            gamelog.nextMessage();

            getkey();

            pool[p]->location=find_courthouse(*pool[p]);
            Armor prisoner(*armortype[getarmortype("ARMOR_PRISONER")]);
            pool[p]->give_armor(prisoner,NULL);
         }
      }
      else if(location[pool[p]->location]->type==SITE_GOVERNMENT_COURTHOUSE)
      { trial(*pool[p]); clearformess=1; }
      else if(location[pool[p]->location]->type==SITE_GOVERNMENT_PRISON)
         if(prison(*pool[p])) clearformess=1;
   }

   //NUKE EXECUTION VICTIMS
   for(p=len(pool)-1;p>=0;p--)
   {
      if(pool[p]->location==-1) continue;

      if(location[pool[p]->location]->type==SITE_GOVERNMENT_PRISON&&!pool[p]->alive)
      {
         removesquadinfo(*pool[p]);
         pool[p]->die();
         pool[p]->location=-1;
      }
   }

   //MUST DO AN END OF GAME CHECK HERE BECAUSE OF EXECUTIONS
   endcheck(END_EXECUTED);

   //DISPERSAL CHECK
   dispersalcheck(clearformess);

   //FUND REPORTS
   if(canseethings)fundreport(clearformess);
   ledger.resetMonthlyAmounts();
   if(clearformess) erase();

   //HEAL CLINIC PEOPLE
   for(p=0;p<len(pool);p++)
   {
      if(disbanding) break;
      if(!(pool[p]->alive)) continue;

      if(pool[p]->clinic>0)
      {
         pool[p]->clinic--;

         for(int w=0;w<BODYPARTNUM;w++)
         {
            if((pool[p]->wound[w]&WOUND_NASTYOFF)||(pool[p]->wound[w]&WOUND_CLEANOFF))
               pool[p]->wound[w]=(char)WOUND_CLEANOFF;
            else pool[p]->wound[w]=0;
         }

         int healthdamage = 0;

         if(pool[p]->special[SPECIALWOUND_RIGHTLUNG]!=1)
         {
            pool[p]->special[SPECIALWOUND_RIGHTLUNG]=1;
            if(LCSrandom(2)) healthdamage++;
         }
         if(pool[p]->special[SPECIALWOUND_LEFTLUNG]!=1)
         {
            pool[p]->special[SPECIALWOUND_LEFTLUNG]=1;
            if(LCSrandom(2)) healthdamage++;
         }
         if(pool[p]->special[SPECIALWOUND_HEART]!=1)
         {
            pool[p]->special[SPECIALWOUND_HEART]=1;
            if(LCSrandom(3)) healthdamage++;
         }
         pool[p]->special[SPECIALWOUND_LIVER]=1;
         pool[p]->special[SPECIALWOUND_STOMACH]=1;
         pool[p]->special[SPECIALWOUND_RIGHTKIDNEY]=1;
         pool[p]->special[SPECIALWOUND_LEFTKIDNEY]=1;
         pool[p]->special[SPECIALWOUND_SPLEEN]=1;
         pool[p]->special[SPECIALWOUND_RIBS]=RIBNUM;

         if(!pool[p]->special[SPECIALWOUND_NECK])
            pool[p]->special[SPECIALWOUND_NECK]=2;
         if(!pool[p]->special[SPECIALWOUND_UPPERSPINE])
            pool[p]->special[SPECIALWOUND_UPPERSPINE]=2;
         if(!pool[p]->special[SPECIALWOUND_LOWERSPINE])
            pool[p]->special[SPECIALWOUND_LOWERSPINE]=2;

         // Inflict permanent health damage
         pool[p]->set_attribute(ATTRIBUTE_HEALTH,pool[p]->get_attribute(ATTRIBUTE_HEALTH,0)-healthdamage);
         if(pool[p]->get_attribute(ATTRIBUTE_HEALTH,0)<=0)
            pool[p]->set_attribute(ATTRIBUTE_HEALTH,1);

         if(pool[p]->blood<=20&&pool[p]->clinic<=2)pool[p]->blood=50;
         if(pool[p]->blood<=50&&pool[p]->clinic<=1)pool[p]->blood=75;

         // If at clinic and in critical condition, transfer to university hospital
         if(pool[p]->clinic > 2 &&
            pool[p]->location > -1 &&
            location[pool[p]->location]->type==SITE_HOSPITAL_CLINIC)
         {
            int hospital=find_hospital(*pool[p]);
            if(hospital!=-1)
            {
               pool[p]->location=hospital;
               set_color(COLOR_WHITE,COLOR_BLACK,1);
               move(8,1);
               addstr(pool[p]->name, gamelog);
               addstr(" has been transferred to ", gamelog);
               addstr(location[hospital]->name, gamelog);
               addstr(".", gamelog);
               gamelog.nextMessage();

               getkey();
            }
         }

         // End treatment
         if(pool[p]->clinic==0)
         {
            pool[p]->blood=100;
            if(clearformess) erase();
            else makedelimiter();

            set_color(COLOR_WHITE,COLOR_BLACK,1);
            move(8,1);
            addstr(pool[p]->name, gamelog);
            addstr(" has left ", gamelog);
            addstr(location[pool[p]->location]->name, gamelog);
            addstr(".", gamelog);
            gamelog.nextMessage();

            int hs=find_homeless_shelter(*pool[p]);
            if(hs==-1) hs=0; //TODO: Error unable to find location

            if(location[pool[p]->base]->siege.siege||
               location[pool[p]->base]->renting==RENTING_NOCONTROL)
               pool[p]->base=hs;

            pool[p]->location=pool[p]->base;

            getkey();
         }
      }
   }
}
コード例 #2
0
/* loads the game from save.dat */
char load(const string& filename)
{
   //LOAD FILE
   int loadversion;
   int l;
   bool dummy_b;
   int dummy;
   long dummy_l;
   FILE *h;

   h=LCSOpenFile(filename.c_str(), "rb", LCSIO_PRE_HOME);
   if(h!=NULL)
   {
      fread(&loadversion,sizeof(int),1,h);

      //NUKE INVALID SAVE GAMES
      if(loadversion<lowestloadversion)
      {
            LCSCloseFile(h);

            reset();

            return 0;
         }

         fread(seed,sizeof(unsigned long),RNG_SIZE,h);

         fread(&mode,sizeof(short),1,h);
         fread(&wincondition,sizeof(short),1,h);
         fread(&fieldskillrate,sizeof(short),1,h);

         fread(&day,sizeof(int),1,h);
         fread(&month,sizeof(int),1,h);
         fread(&year,sizeof(int),1,h);
         fread(&execterm,sizeof(short),1,h);
         fread(&presparty,sizeof(short),1,h);
         fread(&amendnum,sizeof(int),1,h);

         fread(&multipleCityMode,sizeof(bool),1,h);
         fread(&termlimits,sizeof(bool),1,h);
         fread(&deagle,sizeof(bool),1,h);
         fread(&m249,sizeof(bool),1,h);
         fread(&notermlimit,sizeof(bool),1,h);
         fread(&nocourtpurge,sizeof(bool),1,h);
         fread(&stalinmode,sizeof(bool),1,h);

         fread(&stat_recruits,sizeof(int),1,h);
         fread(&stat_dead,sizeof(int),1,h);
         fread(&stat_kills,sizeof(int),1,h);
         fread(&stat_kidnappings,sizeof(int),1,h);
         fread(&stat_buys,sizeof(int),1,h);
         fread(&stat_burns,sizeof(int),1,h);

         fread(&endgamestate,sizeof(char),1,h);
         fread(&ccsexposure,sizeof(char),1,h);
         fread(&ccs_kills,sizeof(char),1,h);

         fread(&Vehicle::curcarid,sizeof(long),1,h);
         fread(&curcreatureid,sizeof(long),1,h);
         fread(&cursquadid,sizeof(long),1,h);
         fread(&police_heat,sizeof(int),1,h);
         fread(&offended_corps,sizeof(short),1,h);
         fread(&offended_cia,sizeof(short),1,h);
         fread(&offended_amradio,sizeof(short),1,h);
         fread(&offended_cablenews,sizeof(short),1,h);
         fread(&offended_firemen,sizeof(short),1,h);
         fread(attorneyseed,sizeof(unsigned long),RNG_SIZE,h);
         //fread(&selectedsiege,sizeof(long),1,h);
         fread(lcityname,sizeof(char),CITY_NAMELEN,h);
         fread(&newscherrybusted,sizeof(char),1,h);

         fread(slogan,sizeof(char),SLOGAN_LEN,h);
         fread(&ledger,sizeof(class Ledger),1,h);
         fread(&party_status,sizeof(short),1,h);

         fread(attitude,sizeof(short),VIEWNUM,h);
         fread(law,sizeof(short),LAWNUM,h);
         fread(house,sizeof(short),HOUSENUM,h);
         fread(senate,sizeof(short),SENATENUM,h);
         fread(court,sizeof(short),COURTNUM,h);
         fread(courtname,sizeof(char)*POLITICIAN_NAMELEN,COURTNUM,h);
         fread(exec,sizeof(char),EXECNUM,h);
         fread(execname,sizeof(char)*POLITICIAN_NAMELEN,EXECNUM,h);
         fread(oldPresidentName,sizeof(char),POLITICIAN_NAMELEN,h);

         //LOCATIONS
         fread(&dummy,sizeof(int),1,h);
         location.resize(dummy);
         for(l=0;l<len(location);l++)
         {
            location[l]=new Location;

            fread(&dummy,sizeof(int),1,h);
            location[l]->loot.resize(dummy);
            for(int l2=0;l2<len(location[l]->loot);l2++)
            {
               int itemLen;
               fread(&itemLen, sizeof(int), 1, h);
               vector<char> vec = vector<char>(itemLen + 1);
               fread(&vec[0], itemLen, 1, h);
               vec[itemLen] = '\0';

               Item* it = create_item(&vec[0]);
               if(it!=NULL)
                  location[l]->loot[l2] = it;
            }
            //Remove items of unknown type.
            for(int l2=len(location[l]->loot)-1; l2>=0; l2--)
            {
               bool del = false;
               if(location[l]->loot[l2]->is_loot())
                  del = (getloottype(location[l]->loot[l2]->get_itemtypename()) == -1);
               else if(location[l]->loot[l2]->is_clip())
                  del = (getcliptype(location[l]->loot[l2]->get_itemtypename()) == -1);
               else if(location[l]->loot[l2]->is_weapon())
                  del = (getweapontype(location[l]->loot[l2]->get_itemtypename()) == -1);
               else if(location[l]->loot[l2]->is_armor())
                  del = (getarmortype(location[l]->loot[l2]->get_itemtypename()) == -1);

               if(del)
               {
                  addstr("Item type ");
                  addstr(location[l]->loot[l2]->get_itemtypename());
                  addstr(" does not exist. Deleting item.");
                  delete_and_remove(location[l]->loot,l2);
               }
            }
            consolidateloot(location[l]->loot); // consolidate loot after loading

            fread(&dummy,sizeof(int),1,h);
            location[l]->changes.resize(dummy);
            for(int l2=0;l2<len(location[l]->changes);l2++)
               fread(&location[l]->changes[l2],sizeof(sitechangest),1,h);

            fread(location[l]->name,sizeof(char),LOCATION_NAMELEN,h);
            fread(location[l]->shortname,sizeof(char),LOCATION_SHORTNAMELEN,h);
            fread(&location[l]->type,sizeof(char),1,h);
            fread(&location[l]->city,sizeof(int),1,h);
            fread(&location[l]->area,sizeof(int),1,h);
            fread(&location[l]->parent,sizeof(int),1,h);
            fread(&location[l]->id,sizeof(int),1,h);

            fread(&location[l]->renting,sizeof(int),1,h);
            fread(&location[l]->newrental,sizeof(char),1,h);
            fread(&location[l]->needcar,sizeof(char),1,h);
            fread(&location[l]->closed,sizeof(int),1,h);
            fread(&location[l]->hidden,sizeof(bool),1,h);
            fread(&location[l]->mapped,sizeof(bool),1,h);
            fread(&location[l]->upgradable,sizeof(bool),1,h);
            fread(&location[l]->highsecurity,sizeof(int),1,h);
            fread(&location[l]->siege,sizeof(siegest),1,h);
            fread(&location[l]->heat,sizeof(int),1,h);
            fread(&location[l]->heat_protection,sizeof(int),1,h);
            fread(&location[l]->compound_walls,sizeof(int),1,h);
            fread(&location[l]->compound_stores,sizeof(int),1,h);
            fread(&location[l]->front_business,sizeof(char),1,h);
            fread(location[l]->front_name,sizeof(char),LOCATION_NAMELEN,h);
            fread(location[l]->front_shortname,sizeof(char),LOCATION_SHORTNAMELEN,h);
            fread(&location[l]->haveflag,sizeof(bool),1,h);

            fread(location[l]->mapseed,sizeof(unsigned long),RNG_SIZE,h);
         }

         //VEHICLES
         fread(&dummy,sizeof(int),1,h);
         vehicle.resize(dummy);
         for(l=0;l<len(vehicle);l++)
         {
            int vehicleLen;
            fread (&vehicleLen, sizeof(int), 1, h);
            vector<char> vec = vector<char> (vehicleLen + 1);
            fread (&vec[0], vehicleLen, 1, h);
            vec[vehicleLen] = '\0';
            vehicle[l] = new Vehicle (&vec[0]);
         }

         //POOL
         fread(&dummy,sizeof(int),1,h);
         pool.resize(dummy);
         for(int pl=0;pl<len(pool);pl++)
         {
            int creatureLen;
            fread (&creatureLen, sizeof(int), 1, h);
            vector<char> vec = vector<char> (creatureLen + 1);
            fread (&vec[0], creatureLen, 1, h);
            vec[creatureLen] = '\0';
            pool[pl] = new Creature(&vec[0]);
            //pool[pl]=new Creature;
            //fread(pool[pl],sizeof(Creature),1,h);
            //read extra interrogation data if applicable
            if(pool[pl]->align==-1 && pool[pl]->alive)
            {
               interrogation* &intr = pool[pl]->activity.intr();
               intr = new interrogation;
               fread(intr->techniques,sizeof(bool[6]),1,h);
               fread(&intr->druguse,sizeof(int),1,h);

               intr->rapport.clear();
               int size;
               fread(&size,sizeof(int),1,h);
               for(int i=0;i<size;i++)
               {
                  long id;
                  float_zero value;
                  fread(&id,sizeof(long),1,h);
                  fread(&value,sizeof(float_zero),1,h);
                  intr->rapport[id]=value;
               }
            }
            /*
            //read equipment
            vector<Item*> dump; //Used to catch invalid pointers from creature so they aren't deleted.
            pool[pl]->drop_weapon(&dump);
            pool[pl]->strip(&dump);
            pool[pl]->clips = deque<Clip*>();
            pool[pl]->extra_throwing_weapons = deque<Weapon*>();
            int itemLen;
            fread(&itemLen, sizeof(int), 1, h);
            if(itemLen != 0)
            {
               vector<char> vec = vector<char>(itemLen + 1);
               fread(&vec[0], itemLen, 1, h);
               vec[itemLen] = '\0';

               Weapon w(&vec[0]);
               if(getweapontype(w.get_itemtypename())!=-1) //Check it is a valid weapon type.
                  pool[pl]->give_weapon(w,&dump);
            }
            //pool[pl]->clips.clear();
            fread(&dummy,sizeof(int),1,h);
            for(int nc=0; nc<dummy; nc++)
            {
               fread(&itemLen, sizeof(itemLen), 1, h);
               vector<char> vec = vector<char>(itemLen + 1);
               fread(&vec[0], itemLen, 1, h);
               vec[itemLen] = '\0';

               Clip c(&vec[0]);
               if(getcliptype(c.get_itemtypename())!=-1) //Check it is a valid clip type.
                  pool[pl]->take_clips(c,len(c));
            }
            //pool[pl]->extra_throwing_weapons.clear();
            fread(&dummy,sizeof(int),1,h);
            for(int ne=0; ne<dummy; ne++)
            {
               fread(&itemLen, sizeof(itemLen), 1, h);
               vector<char> vec = vector<char>(itemLen + 1);
               fread(&vec[0], itemLen, 1, h);
               vec[itemLen] = '\0';

               Weapon w(&vec[0]);
               if(getweapontype(w.get_itemtypename())!=-1) //Check it is a valid weapon type.
                  pool[pl]->give_weapon(w,NULL);
            }
            fread(&itemLen, sizeof(itemLen), 1, h);
            if(itemLen != 0)
            {
               vector<char> vec = vector<char>(itemLen + 1);
               fread(&vec[0], itemLen, 1, h);
               vec[itemLen] = '\0';

               Armor a(&vec[0]);
               if(getarmortype(a.get_itemtypename())!=-1) //Check it is a valid armor type.
                  pool[pl]->give_armor(a,&dump);
            }*/
         }

         //Unique Creatures
         {
            int uniquecreaturesLen;
            fread (&uniquecreaturesLen, sizeof(int), 1, h);
            vector<char> vec = vector<char> (uniquecreaturesLen + 1);
            fread (&vec[0], uniquecreaturesLen, 1, h);
            vec[uniquecreaturesLen] = '\0';
            uniqueCreatures = UniqueCreatures(&vec[0]);
            //fread(&uniqueCreatures,sizeof(UniqueCreatures),1,h);
         }

         //SQUADS
         fread(&dummy,sizeof(int),1,h);
         squad.resize(dummy);
         for(int sq=0;sq<len(squad);sq++)
         {
            squad[sq]=new squadst;

            fread(squad[sq]->name,sizeof(char),SQUAD_NAMELEN,h);
            fread(&squad[sq]->activity,sizeof(activityst),1,h);
            fread(&squad[sq]->id,sizeof(int),1,h);

            for(int pos=0;pos<6;pos++)
            {
               //REBUILD SQUAD FROM POOL
               squad[sq]->squad[pos]=NULL;
               fread(&dummy_b,sizeof(bool),1,h);
               if(dummy_b)
               {
                  int dummy_i;
                  fread(&dummy_i,sizeof(int),1,h);
                  for(int pl=0;pl<len(pool);pl++)
                     if(pool[pl]->id==dummy_i)
                        squad[sq]->squad[pos]=pool[pl];
               }
            }

            fread(&dummy,sizeof(int),1,h);
            squad[sq]->loot.resize(dummy);
            for(int l2=0;l2<len(squad[sq]->loot);l2++)
            {
               int itemLen;
               fread(&itemLen, sizeof(int), 1, h);
               vector<char> vec = vector<char>(itemLen + 1);
               fread(&vec[0], itemLen, 1, h);
               vec[itemLen] = '\0';

               Item* it = create_item(&vec[0]);
               //if(it!=NULL) //Assume save file is correct? -XML
                  squad[sq]->loot[l2] = it;
               /*else
                  squad[sq]->loot.erase(loot.begin()+l2--);*/
            }
            //Remove items of unknown type.
            for(int l2=len(squad[sq]->loot)-1; l2>=0; l2--)
            {
               bool del = false;
               if(squad[sq]->loot[l2]->is_loot())
                  del = (getloottype(squad[sq]->loot[l2]->get_itemtypename()) == -1);
               else if(squad[sq]->loot[l2]->is_clip())
                  del = (getcliptype(squad[sq]->loot[l2]->get_itemtypename()) == -1);
               else if(squad[sq]->loot[l2]->is_weapon())
                  del = (getweapontype(squad[sq]->loot[l2]->get_itemtypename()) == -1);
               else if(squad[sq]->loot[l2]->is_armor())
                  del = (getarmortype(squad[sq]->loot[l2]->get_itemtypename()) == -1);

               if(del)
               {
                  addstr("Item type ");
                  addstr(squad[sq]->loot[l2]->get_itemtypename());
                  addstr(" does not exist. Deleting item.");
                  delete_and_remove(squad[sq]->loot,l2);
               }
            }
            consolidateloot(squad[sq]->loot); // consolidate loot after loading
         }

         activesquad=NULL;
         fread(&dummy_b,sizeof(bool),1,h);
         if(dummy_b)
         {
            int dummy_i;
            fread(&dummy_i,sizeof(int),1,h);
            for(int sq=0;sq<len(squad);sq++)
               if(squad[sq]->id==dummy_i)
               {
                  activesquad=squad[sq];
                  break;
               }
         }

         //DATES
         fread(&dummy,sizeof(int),1,h);
         date.resize(dummy);
         for(int dt=0;dt<len(date);dt++)
         {
            date[dt]=new datest;

            fread(&date[dt]->mac_id,sizeof(long),1,h);
            fread(&date[dt]->timeleft,sizeof(short),1,h);
            fread(&date[dt]->city,sizeof(int),1,h);

            fread(&dummy,sizeof(int),1,h);
            date[dt]->date.resize(dummy);
            for(int dt2=0;dt2<len(date[dt]->date);dt2++)
            {
               int creatureLen;
               fread (&creatureLen, sizeof(int), 1, h);
               vector<char> vec = vector<char> (creatureLen + 1);
               fread (&vec[0], creatureLen, 1, h);
               vec[creatureLen] = '\0';
               date[dt]->date[dt2] = new Creature(&vec[0]);

               //date[dt]->date[dt2]=new Creature;
               //fread(date[dt]->date[dt2],sizeof(Creature),1,h);
            }
         }

         //RECRUITS
         fread(&dummy,sizeof(int),1,h);
         recruit.resize(dummy);
         for(int rt=0;rt<len(recruit);rt++)
         {
            recruit[rt]=new recruitst;
            fread(&recruit[rt]->recruiter_id,sizeof(long),1,h);
            fread(&recruit[rt]->timeleft,sizeof(short),1,h);
            fread(&recruit[rt]->level,sizeof(char),1,h);
            fread(&recruit[rt]->eagerness1,sizeof(char),1,h);
            fread(&recruit[rt]->task,sizeof(char),1,h);

            int creatureLen;
            fread (&creatureLen, sizeof(int), 1, h);
            vector<char> vec = vector<char> (creatureLen + 1);
            fread (&vec[0], creatureLen, 1, h);
            vec[creatureLen] = '\0';
            recruit[rt]->recruit = new Creature(&vec[0]);
            //recruit[rt]->recruit = new Creature;
            //fread(recruit[rt]->recruit,sizeof(Creature),1,h);
         }

         //NEWS STORIES
         fread(&dummy,sizeof(int),1,h);
         newsstory.resize(dummy);
         for(int ns=0;ns<len(newsstory);ns++)
         {
            newsstory[ns]=new newsstoryst;

            fread(&newsstory[ns]->type,sizeof(short),1,h);
            fread(&newsstory[ns]->view,sizeof(short),1,h);

            fread(&newsstory[ns]->loc,sizeof(long),1,h);
            fread(&newsstory[ns]->priority,sizeof(long),1,h);
            fread(&newsstory[ns]->page,sizeof(long),1,h);
            fread(&newsstory[ns]->positive,sizeof(char),1,h);
            fread(&newsstory[ns]->siegetype,sizeof(short),1,h);

            newsstory[ns]->cr=NULL;
            fread(&dummy_b,sizeof(bool),1,h);
            if(dummy_b)
            {
               fread(&dummy_l,sizeof(long),1,h);
               for(int pl=0;pl<len(pool);pl++)
                  if(pool[pl]->id==dummy_l)
                  {
                     newsstory[ns]->cr=pool[pl];
                     break;
                  }
            }

            fread(&dummy,sizeof(int),1,h);
            newsstory[ns]->crime.resize(dummy);
            for(int dt2=0;dt2<len(newsstory[ns]->crime);dt2++)
               fread(&newsstory[ns]->crime[dt2],sizeof(int),1,h);
         }

         // Liberal Media
         fread(public_interest,sizeof(public_interest),1,h);
         fread(background_liberal_influence,sizeof(background_liberal_influence),1,h);

         // Site mode options
         fread(&encounterwarnings,sizeof(bool),1,h);
         bool musicenabled;
         fread(&musicenabled,sizeof(bool),1,h);
         music.enableIf(musicenabled);

         LCSCloseFile(h);

         // Check that vehicles are of existing types.
         for(int v=0;v<len(vehicle);v++)
         {
            if(getvehicletype(vehicle[v]->vtypeidname())==-1)
            { //Remove vehicle of non-existing type.
               addstr("Vehicle type "+vehicle[v]->vtypeidname()+" does not exist. Deleting vehicle.");
               delete_and_remove(vehicle,v--);
            }
         }

         return 1;
      }

   gamelog.log("Could not load");
   return 0;
}
コード例 #3
0
bool confirmdisband()                      // concerned should be (slightly) more likely
{                                          // to be the phrase. (Issue, not the CCS, etc.)
   static const char *issue_phrases[] =    //    -- LK
   {  /////////////////////////////////////////////////////////////////////////////////////////
      // Liberal Phrase           // Conservative Equivalent  // Stalinist Equivalent        //
      /////////////////////////////////////////////////////////////////////////////////////////
      "Corporate Accountability", // Deregulation             // Nationalized Industry       //
      "Free Speech",              // Child Safety             // Ideological Purity          //
      "Gay Marriage",             // Sanctity of Marriage     // Bourgeoisie Decadence       //
      "Abortion Rights",          // Right to Life            // Population Control          //
      "Separation Clause",        // Under God                // Opiate of the Masses        //
      "Racial Equality",          // Emmett Till              // Kulaks                      //
      "Gun Control",              // Second Amendment         // Firing Squad                //
      "Campaign Finance Reform",  // Freedom to Campaign      // People's Republic           //
      "Animal Rights",            // Animal Abuse             // Capitalist Pig-Dogs         //
      "Worker's Rights",          // Right to Work            // Canadian Gulags             //
      "Police Responsibility",    // Rodney King              // Secret Police               // /* XXX: "Civilian" Police (Note to self) -- LK */
      "Global Warming",           // Self-Regulation          // Five-Year Plan              //
      "Immigration Reform",       // Border Control           // Iron Curtain                // /* XXX: "Nicer" Term (Note to self) -- LK */
      "Human Rights",             // National Security        // Reeducation                 // /* XXX: 2+2 = 5? (Note to self) -- LK */
      "Woman's Suffrage",         // Traditional Gender Roles // Honey Trap                  //
      "Right To Privacy",         // Wiretapping              // Stasi                       //
      "Medical Marijuana",        // War on Drugs             // Vodka                       //
      "Flag Burning",             // Patriotism               // Hammer and Sickle           // /* XXX: Towards the beginning of 1984, at Winston's job. (Note to self) -- LK */
      "Life Imprisonment",        // Zero Tolerance           // Mass Grave                  //
      "Conflict Resolution",      // Preemptive Strike        // Mutual Assured Destruction  //
      "Radiation Poisoning",      // Nuclear Power            // Chernobyl                   //
      "Tax Bracket"               // Flat Tax                 // Proletariat                 //
   }; /////////////////////////////////////////////////////////////////////////////////////////

   string word=pickrandom(issue_phrases);

   for(int pos=0;pos<len(word);)
   {
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,1);
      mvaddstr(0,0,"Are you sure you want to disband?");

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      mvaddstr(2,0,"Disbanding scatters the Liberal Crime Squad, sending all of its members");
      mvaddstr(3,0,"into hiding, free to pursue their own lives.  You will be able to observe");
      mvaddstr(4,0,"the political situation in brief, and wait until a resolution is reached.");

      mvaddstr(6,0,"If at any time you determine that the Liberal Crime Squad will be needed");
      mvaddstr(7,0,"again, you may return to the homeless shelter to restart the campaign.");

      mvaddstr(9,0,"Do not make this decision lightly.  If you do need to return to action,");
      mvaddstr(10,0,"only the most devoted of your former members will return.");

      set_color(COLOR_WHITE,COLOR_BLACK,1);
      mvaddstr(13,0,"Type this Liberal phrase to confirm (press a wrong letter to rethink it):");

      for(int x=0;x<len(word);x++)
      {
         if(x==pos) set_color(COLOR_GREEN,COLOR_BLACK,0);
         else if(x<pos) set_color(COLOR_GREEN,COLOR_BLACK,1);
         else set_color(COLOR_WHITE,COLOR_BLACK,0);
         mvaddchar(15,x,word[x]);
      }

      if(getkey()==::tolower(word[pos]))
      {
         pos++;
         if(word[pos]==' '||word[pos]=='\''||word[pos]=='-') pos++;
      }
      else return false;
   }
   //SET UP THE DISBAND
   for(int p=len(pool)-1;p>=0;p--)
   {
      if(!pool[p]->alive || pool[p]->flag&CREATUREFLAG_KIDNAPPED || pool[p]->flag&CREATUREFLAG_MISSING) delete_and_remove(pool,p);
      else if(!(pool[p]->flag&CREATUREFLAG_SLEEPER))
      {
         removesquadinfo(*pool[p]);
         pool[p]->hiding=-1;
      }
   }
   cleangonesquads();
   disbandtime=year;
   return true;
}
コード例 #4
0
/* base - liberal agenda - disband */
char confirmdisband(void) // The (current) issue that the masses are most
{                         //        concerned should be (slightly) more likely
   char word[80];         //        to be the phrase. (Issue, not the CCS, etc.)
   int pos=0;             //                        -- LK

   switch(LCSrandom(22)) // or more... (preferably 44)
   {    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Liberal Phrase                                       // Conservative Equivalent      // Stalinist Equivalent  //
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      case 0:strcpy(word,"Corporate Accountability");break;     // Deregulation                 //                       //
      case 1:strcpy(word,"Free Speech");break;                  // Child Safety                 // Thoughtcrime          //
      case 2:strcpy(word,"Gay Marriage");break;                 // Sancitity of Marriage        //                       //
      case 3:strcpy(word,"Abortion Rights");break;              // Right to Life                //                       //
      case 4:strcpy(word,"Separation Clause");break;            // Under God                    //                       //
      case 5:strcpy(word,"Racial Equality");break;              // Emmett Till                  //                       //
      case 6:strcpy(word,"Gun Control");break;                  // Second Amendment             // Firing Squad          //
      case 7:strcpy(word,"Campaign Finance Reform");break;      // Freedom to Campaign          //                       //
      case 8:strcpy(word,"Animal Rights");break;                // Animal Abuse                 //                       //
      case 9:strcpy(word,"Worker's Rights");break;              // Right to Work                // Gulag                 //
      case 10:strcpy(word,"Police Responsibility");break;       // Rodney King                  // Red Guard FIXME       // /* XXX: "Civilian" Police (Note to self) -- LK */
      case 11:strcpy(word,"Global Warming");break;              // Self-Regulation              //                       //
      case 12:strcpy(word,"Immigration Reform");break;          // Border Control FIXME         // Berlin Wall           // /* XXX: "Nicer" Term (Note to self) -- LK */
      case 13:strcpy(word,"Human Rights");break;                // National Security            // Reeducation FIXME     // /* XXX: 2+2 = 5? (Note to self) -- LK */
      case 14:strcpy(word,"Woman's Suffrage");break;            // Traditional Gender Roles     //                       //
      case 15:strcpy(word,"Right To Privacy");break;            // Wiretapping                  // Big Brother           //
      case 16:strcpy(word,"Medical Marijuana");break;           // War on Drugs                 // Soma                  //
      case 17:strcpy(word,"Flag Burning");break;                // Patriotism                   // DAILYSPEECHORW/E FIXME// /* XXX: Towards the beginning of 1984, at Winston's job. (Note to self) -- LK */
      case 18:strcpy(word,"Life Imprisonment");break;           // Zero Tolerance               // Mass Grave            //
      case 19:strcpy(word,"Conflict Resolution");break;         // Preemptive Strike            // Cuban Missile Crisis  //
      case 20:strcpy(word,"Radiation Poisoning");break;         // Nuclear Power                // Arms Race             //
      case 21:strcpy(word,"Tax Bracket");break;                 // Flat Tax                     // Proletariat           //
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   }

   do
   {
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,1);
      move(0,0);
      addstr("Are you sure you want to disband?");

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(2,0);  addstr("Disbanding scatters the Liberal Crime Squad, sending all of its members");
      move(3,0);  addstr("into hiding, free to pursue their own lives.  You will be able to observe");
      move(4,0);  addstr("the political situation in brief, and wait until a resolution is reached.");

      move(6,0);  addstr("If at any time you determine that the Liberal Crime Squad will be needed");
      move(7,0);  addstr("again, you may return to the homeless shelter to restart the campaign.");

      move(9,0);  addstr("Do not make this decision lightly.  If you do need to return to action,");
      move(10,0); addstr("only the most devoted of your former members will return.");

      set_color(COLOR_WHITE,COLOR_BLACK,1);
      move(13,0); addstr("Type this Liberal phrase to confirm (press a wrong letter to rethink it):");

      for(int x=0;x<(int)strlen(word);x++)
      {
         move(15,x);
         if(x==pos)set_color(COLOR_GREEN,COLOR_BLACK,0);
         else if(x<pos)set_color(COLOR_GREEN,COLOR_BLACK,1);
         else set_color(COLOR_WHITE,COLOR_BLACK,0);
         addch(word[x]);
      }

      int c=getch();
      translategetch(c);

      if((c==word[pos])||((c+'A'-'a')==word[pos]))
      {
         pos++;
         if(word[pos]==' ')pos++;
         if(pos>=(int)strlen(word))
         {
            //SET UP THE DISBAND
            for(int p=pool.size()-1;p>=0;p--)
            {
               if(!pool[p]->alive)delete_and_remove(pool,p);
               else if(!(pool[p]->flag & CREATUREFLAG_SLEEPER))
               {
                  removesquadinfo(*pool[p]);
                  pool[p]->hiding=-1;
               }
            }
            cleangonesquads();
            disbandtime=year;
            return 1;
         }
      }
      else break;
   }while(1);
   return 0;
}
コード例 #5
0
/* active squad visits the car dealership */
void dealership(int loc)
{
   music.play(MUSIC_SHOPPING);
   short buyer=0;

   locatesquad(activesquad,loc);

   int partysize=squadsize(activesquad);

   while(true)
   {
      erase();

      locheader();
      printparty();

      Creature *sleepercarsalesman=NULL;
      for(int p=0;p<len(pool);p++)
         if(pool[p]->alive&&(pool[p]->flag & CREATUREFLAG_SLEEPER)&&
            pool[p]->type==CREATURE_CARSALESMAN&&location[pool[p]->location]->city==location[loc]->city)
            sleepercarsalesman=pool[p];

      Vehicle* car_to_sell=0;
      int price=0;

      for(int v=len(vehicle)-1;v>=0;v--)
         if(vehicle[v]->id()==activesquad->squad[buyer]->carid)
            car_to_sell = vehicle[v];

      if(!car_to_sell) set_color(COLOR_WHITE,COLOR_BLACK,0);
      else set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(10,1);
      addstr("G - Get a Liberal car");

      move(11,1);
      if(car_to_sell)
      {
         price = static_cast<int>(0.8*car_to_sell->price());

         if(car_to_sell->get_heat())
            price/=10;
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         addstr("S - Sell the "+car_to_sell->fullname()+" ($"+tostring(price)+")");
      }
      else
      {
         set_color(COLOR_BLACK,COLOR_BLACK,1);
         addstr("S - Sell a car");
      }

      /*if(car_to_sell && car_to_sell->heat>1 && ledger.get_funds()>=500)
         set_color(COLOR_WHITE,COLOR_BLACK,0);
      else
         set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(12,1);
      addstr("P - Repaint car, replace plates and tags ($500)");*/

      if(partysize>=2)set_color(COLOR_WHITE,COLOR_BLACK,0);
      else set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(16,1);
      addstr("B - Choose a buyer");

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(16,40);
      addstr("Enter - Leave");

      if(party_status!=-1)set_color(COLOR_WHITE,COLOR_BLACK,0);
      else set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(15,1);
      addstr("0 - Show the squad's Liberal status");
      if(partysize>0&&(party_status==-1||partysize>1))set_color(COLOR_WHITE,COLOR_BLACK,0);
      else set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(15,40);
      addstr("# - Check the status of a squad Liberal");

      int c=getkey();

      // Leave
      if(c=='x'||c==ENTER||c==ESC||c==SPACEBAR)break;

      //Sell the car
      if(c=='s' && car_to_sell)
      {
         ledger.add_funds(price,INCOME_CARS);
         for(int v=len(vehicle)-1;v>=0;v--)
            if(vehicle[v]==car_to_sell)
            {
            	delete_and_remove(vehicle,v);
               break;
            }
      }

      // Get a car
      if(c=='g' && !car_to_sell)
      {
         int carchoice;

         vector<int> availablevehicle;
         vector<string> vehicleoption;
         for(int i=0;i<len(vehicletype);i++)
            if (vehicletype[i]->availableatshop())
            {
               availablevehicle.push_back(i);
               vehicleoption.push_back(vehicletype[i]->longname()+" ($"+
                  tostring(sleepercarsalesman?vehicletype[i]->sleeperprice():vehicletype[i]->price())+")");
            }
         while(true)
         {
            carchoice = choiceprompt("Choose a vehicle","",vehicleoption,"Vehicle",
                                     true,"We don't need a Conservative car");
            if (carchoice!=-1 && (sleepercarsalesman?vehicletype[availablevehicle[carchoice]]->sleeperprice():
                                  vehicletype[availablevehicle[carchoice]]->price()) > ledger.get_funds())
            {
               set_color(COLOR_RED,COLOR_BLACK,0);
               move(1,1);
               addstr("You don't have enough money!");

               getkey();
            }
            else break;
         }

         if(carchoice==-1) continue;

         //Picked a car, pick color
         int colorchoice;
         //if(len(vehicletype[availablevehicle[choice]]->color())>1) //Allow to back out if you don't like single colour? -XML
         //{
         colorchoice = choiceprompt("Choose a color","",vehicletype[availablevehicle[carchoice]]->color(),
                                    "Color",true,"These colors are Conservative");
         //}
         //else
         //   colorchoice = 0;

         if(colorchoice==-1) continue;

         Vehicle *v=new Vehicle(*vehicletype[availablevehicle[carchoice]],
                                vehicletype[availablevehicle[carchoice]]->color()[colorchoice],year);
         activesquad->squad[buyer]->pref_carid = v->id();
         vehicle.push_back(v);

         ledger.subtract_funds((sleepercarsalesman?v->sleeperprice():v->price()),EXPENSE_CARS);
      }

      // Reduce heat
      /*if(c=='p' && car_to_sell && car_to_sell->heat>1 && ledger.get_funds()>=500)
      {
         funds-=500;
         moneylost_goods+=500;
         car_to_sell->heat=1;
      }*/

      if(c=='b')choose_buyer(buyer);

      if(c=='0')party_status=-1;

      if(c>='1'&&c<='6'&&activesquad!=NULL)
         if(activesquad->squad[c-'1']!=NULL)
         {
            if(party_status==c-'1')fullstatus(party_status);
            else party_status=c-'1';
         }

   }
}
コード例 #6
0
/* monthly - lets the player choose a special edition for the guardian */
int choosespecialedition(char &clearformess)
{
   //Temporary, maybe put special edition definition into an xml file. -XML
	static const string document_types[] =
	{  // This list MUST be in alphabetical order for binary_search() to work right
      "LOOT_AMRADIOFILES",
      "LOOT_CABLENEWSFILES",
      "LOOT_CCS_BACKERLIST",
      "LOOT_CEOLOVELETTERS",
      "LOOT_CEOPHOTOS",
      "LOOT_CEOTAXPAPERS",
      "LOOT_CORPFILES",
      "LOOT_INTHQDISK",
      "LOOT_JUDGEFILES",
      "LOOT_POLICERECORDS",
      "LOOT_PRISONFILES",
      "LOOT_RESEARCHFILES",
      "LOOT_SECRETDOCUMENTS"
	};
	static const vector<string> dox(document_types,document_types+len(document_types));

   int page=0;

   //char havetype[LOOTNUM];
   //for(int l=0;l<LOOTNUM;l++)havetype[l]=0;
   vector<bool> havetype(len(loottype),false);
   vector<int> loottypeindex;

   //FIND ALL LOOT TYPES
   for(int loc=0;loc<len(location);loc++)
   {
      if(location[loc]->renting==RENTING_NOCONTROL) continue;

      consolidateloot(location[loc]->loot);
      for(int l=0;l<len(location[loc]->loot);l++)
      {
         if(!location[loc]->loot[l]->is_loot()) continue;
         if(!binary_search(dox.begin(),dox.end(),location[loc]->loot[l]->get_itemtypename())) continue;

         if(!havetype[getloottype(location[loc]->loot[l]->get_itemtypename())])
         {
            loottypeindex.push_back(getloottype(location[loc]->loot[l]->get_itemtypename()));
            havetype[getloottype(location[loc]->loot[l]->get_itemtypename())]=true;
         }
      }
   }
   for(int sq=0;sq<len(squad);sq++)
   {
      consolidateloot(squad[sq]->loot);
      for(int l=0;l<len(squad[sq]->loot);l++)
      {
         if(!squad[sq]->loot[l]->is_loot()) continue;
         if(!binary_search(dox.begin(),dox.end(),squad[sq]->loot[l]->get_itemtypename())) continue;

         if(!havetype[getloottype(squad[sq]->loot[l]->get_itemtypename())])
         {
            loottypeindex.push_back(getloottype(squad[sq]->loot[l]->get_itemtypename()));
            havetype[getloottype(squad[sq]->loot[l]->get_itemtypename())]=true;
         }
      }
   }

   if(!len(loottypeindex)) return -1;

   clearformess=1;

   //PICK ONE
   while(true)
   {
      music.play(MUSIC_NEWSPAPER);
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(0,0);
      addstr("Do you want to run a special edition?");

      int x=1,y=10;
      char str[200];

      for(int l=page*18;l<len(loottypeindex)&&l<page*18+18;l++)
      {
         str[0]=l-page*18+'A';
         str[1]='\x0';
         strcat(str," - ");
         strcat(str,loottype[loottypeindex[l]]->get_name());

         move(y,x);
         addstr(str);

         x+=26;
         if(x>53) x=1,y++;
      }

      //PAGE UP
      if(page>0)
      {
         move(17,1);
         addprevpagestr();
      }
      //PAGE DOWN
      if((page+1)*18<len(loottype))
      {
         move(17,53);
         addnextpagestr();
      }

      move(24,1);
      addstr("Enter - Not in this month's Liberal Guardian");

      int c=getkey();

      if(c>='a'&&c<='r')
      {
         int slot=c-'a'+page*18;

         if(slot>=0&&slot<len(loottypeindex))
         {
            //DELETE THE ITEM
            for(int loc=0;loc<len(location);loc++)
            {
               if(location[loc]->renting==RENTING_NOCONTROL) continue;

               for(int l=0;l<len(location[loc]->loot);l++)
               {
                  if(!location[loc]->loot[l]->is_loot()) continue;

                  if(getloottype(location[loc]->loot[l]->get_itemtypename())==loottypeindex[slot])
                  {
                     location[loc]->loot[l]->decrease_number(1);
                     if(location[loc]->loot[l]->empty())
                     	delete_and_remove(location[loc]->loot,l);
                     return loottypeindex[slot];
                  }
               }
            }
            for(int sq=0;sq<len(squad);sq++)
            {
               for(int l=0;l<len(squad[sq]->loot);l++)
               {
                  if(!squad[sq]->loot[l]->is_loot()) continue;

                  if(getloottype(squad[sq]->loot[l]->get_itemtypename())==loottypeindex[slot])
                  {
                     squad[sq]->loot[l]->decrease_number(1);
                     if(squad[sq]->loot[l]->empty())
                        delete_and_remove(squad[sq]->loot,l);
                     return loottypeindex[slot];
                  }
               }
            }

            //WHOOPS!
            return loottypeindex[slot];
         }
      }

      if(c=='x'||c==ENTER||c==ESC||c==SPACEBAR) return -1;

      //PAGE UP
      if((c==interface_pgup||c==KEY_UP||c==KEY_LEFT)&&page>0) page--;
      //PAGE DOWN
      if((c==interface_pgdn||c==KEY_DOWN||c==KEY_RIGHT)&&(page+1)*18<len(loottype)) page++;

   }

   return -1;
}
コード例 #7
0
int Shop::fenceselect(squadst& customers) const
{
   int ret=0;

   consolidateloot(location[customers.squad[0]->base]->loot);

   int page=0;

   vector<int> selected(location[customers.squad[0]->base]->loot.size(),0);

   do
   {
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(0,0);
      addstr("What will you sell?");

      if (ret > 0)
      {
         move(0,30);
         addstr("Estimated Liberal Amount: $");
         addstr(tostring(ret).c_str());
      }

      printparty();

      int x = 1, y = 10;
      std::string outstr;
      std::string itemstr;

      for (int l = page * 18;
           l < (int)location[customers.squad[0]->base]->loot.size() && l < page * 18 + 18;
           l++)
      {
         if (selected[l])
            set_color(COLOR_GREEN,COLOR_BLACK,1);
         else
            set_color(COLOR_WHITE,COLOR_BLACK,0);
         itemstr = location[customers.squad[0]->base]->loot[l]->equip_title();
         if (location[customers.squad[0]->base]->loot[l]->get_number() > 1)
         {
            if(selected[l] > 0)
            {
               itemstr += " " + tostring(selected[l]) + "/";
            }
            else
               itemstr += " x";
            itemstr += tostring(location[customers.squad[0]->base]->loot[l]->get_number());
         }

         outstr = static_cast<char>(l - page * 18 + 'A');
         outstr += " - " + itemstr;

         move(y,x);
         addstr(outstr.c_str());

         x += 26;
         if (x > 53)
         {
            x = 1;
            y++;
         }
      }

      //PAGE UP
      set_color(COLOR_WHITE,COLOR_BLACK,0);
      if (page > 0)
      {
         move(17,1);
         addprevpagestr();
      }
      //PAGE DOWN
      if((page + 1) * 18 < (int)location[customers.squad[0]->base]->loot.size())
      {
         move(17,53);
         addnextpagestr();
      }

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(23,1);
      addstr("Press a letter to select an item to sell.");
      move(24,1);
      addstr("Enter - Done");

      refresh();

      int c = getch();
      translategetch(c);

      if (c >= 'a' && c <= 'r')
      {
         int slot = c - 'a' + page * 18;

         if(slot >= 0 && slot < (int)location[customers.squad[0]->base]->loot.size())
         {
            if (selected[slot])
            {
               ret -= location[customers.squad[0]->base]->loot[slot]->get_fencevalue() * selected[slot];
               selected[slot] = 0;
            }
            else
            {
               if (!location[customers.squad[0]->base]->loot[slot]->is_good_for_sale())
               {
                  printparty();

                  move(8,15);
                  set_color(COLOR_WHITE,COLOR_BLACK,1);
                  addstr(" You can't sell damaged goods.");

                  refresh();
                  getch();
               }
               else
               {
                  if (location[customers.squad[0]->base]->loot[slot]->get_number() > 1)
                  {
                     selected[slot] = 1;

                     printparty();

                     move(8,15);
                     set_color(COLOR_WHITE,COLOR_BLACK,1);
                     addstr("       How many?          ");

                     refresh();

                     char str[100];

                     keypad(stdscr,FALSE);
                     raw_output(FALSE);
                     echo();
                     curs_set(1);
                     mvgetstr(8,32,str);
                     curs_set(0);
                     noecho();
                     raw_output(TRUE);
                     keypad(stdscr,TRUE);

                     selected[slot] = atoi(str);
                     if (selected[slot] < 0)
                        selected[slot] = 0;
                     else if (selected[slot] > location[customers.squad[0]->base]->loot[slot]->get_number())
                        selected[slot]=location[customers.squad[0]->base]->loot[slot]->get_number();
                  }
                  else
                     selected[slot]=1;
                  ret += location[customers.squad[0]->base]->loot[slot]->get_fencevalue() * selected[slot];
               }
            }
         }
      }

      if(c == 'x'||c==10||c==ESC)
         break;

      //PAGE UP
      if((c == interface_pgup || c == KEY_UP || c == KEY_LEFT) && page > 0)
         page--;
      //PAGE DOWN
      if((c == interface_pgdn || c == KEY_DOWN || c == KEY_RIGHT)
         && (page + 1) * 18 < (int)location[customers.squad[0]->base]->loot.size())
         page++;

   } while (true);

   for(int l = location[customers.squad[0]->base]->loot.size() - 1; l >= 0; l--)
   {
      if(selected[l] > 0)
      {
         location[customers.squad[0]->base]->loot[l]->decrease_number(selected[l]);
         if(location[customers.squad[0]->base]->loot[l]->get_number() <= 0)
            delete_and_remove(location[customers.squad[0]->base]->loot,l);
      }
   }

   return ret;
}
コード例 #8
0
void Shop::sell_loot(squadst& customers) const
{
   int partysize=0;
   for(int p=0;p<6;p++)
   {
      if(customers.squad[p]!=NULL)
      {
         partysize++;
      }
   }

   do
   {
      erase();

      locheader();
      printparty();

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(10,1);
      addstr("E - Look over Equipment");

      if (location[customers.squad[0]->base]->loot.size() > 0)
         set_color(COLOR_WHITE,COLOR_BLACK,0);
      else
         set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(10,40);
      addstr("F - Pawn Selectively");

      if (location[customers.squad[0]->base]->loot.size() > 0)
         set_color(COLOR_WHITE,COLOR_BLACK,0);
      else
         set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(11,1);
      addstr("W - Pawn all Weapons");

      if (location[customers.squad[0]->base]->loot.size() > 0)
         set_color(COLOR_WHITE,COLOR_BLACK,0);
      else
         set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(11,40);
      addstr("A - Pawn all Ammunition");

      if (location[customers.squad[0]->base]->loot.size() > 0)
         set_color(COLOR_WHITE,COLOR_BLACK,0);
      else
         set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(12,1);
      addstr("C - Pawn all Clothes");

      if (location[customers.squad[0]->base]->loot.size() > 0)
         set_color(COLOR_WHITE,COLOR_BLACK,0);
      else
         set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(12,40);
      addstr("L - Pawn all Loot");

      if (party_status != -1)
         set_color(COLOR_WHITE,COLOR_BLACK,0);
      else
         set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(15,1);
      addstr("0 - Show the squad's Liberal status");

      if (partysize > 0 && (party_status == -1 || partysize > 1))
         set_color(COLOR_WHITE,COLOR_BLACK,0);
      else
         set_color(COLOR_BLACK,COLOR_BLACK,1);
      move(15,40);
      addstr("# - Check the status of a squad Liberal");

      set_color(COLOR_WHITE,COLOR_BLACK,0);
      move(16,40);
      addstr("Enter - Done pawning");

      int c = getch();
      translategetch(c);

      if (c == 10)
         break;

      if (c == 'e' && customers.squad[0]->base != -1)
         equip(location[customers.squad[0]->base]->loot, -1);

      if (c == 'w' || c == 'a' || c == 'c')
      {
         move(18,1);
         set_color(COLOR_WHITE,COLOR_BLACK,1);
         switch (c)
         {
            case 'w':
               addstr("Really sell all weapons? (Y)es to confirm.           ");
               break;
            case 'a':
               addstr("Really sell all ammo? (Y)es to confirm.              ");
               break;
            case 'c':
               addstr("Really sell all clothes? (Y)es to confirm.           ");
               break;
         }
         int c2 = getch();
         translategetch(c2);
         if (c2 != 'y')
         {
            c = 0;//no sale
         }
      }

      if((c == 'w' || c == 'c' || c == 'l' || c == 'a' || c == 'f') &&
         location[customers.squad[0]->base]->loot.size() > 0)
      {
         int fenceamount=0;

         if (c == 'f')
            fenceamount = fenceselect(customers);
         else
         {
            for (int l = location[customers.squad[0]->base]->loot.size() - 1; l >= 0; l--)
            {
               if (c == 'w' && location[customers.squad[0]->base]->loot[l]->is_weapon()
                   && location[customers.squad[0]->base]->loot[l]->is_good_for_sale())
               {
                  fenceamount += location[customers.squad[0]->base]->loot[l]->get_fencevalue()
                                 * location[customers.squad[0]->base]->loot[l]->get_number();
                  delete_and_remove(location[customers.squad[0]->base]->loot,l);
               }
               else if (c == 'c' && location[customers.squad[0]->base]->loot[l]->is_armor()
                        && location[customers.squad[0]->base]->loot[l]->is_good_for_sale())
               {
                  fenceamount += location[customers.squad[0]->base]->loot[l]->get_fencevalue()
                                 * location[customers.squad[0]->base]->loot[l]->get_number();
                  delete_and_remove(location[customers.squad[0]->base]->loot,l);
               }
               else if (c == 'a' && location[customers.squad[0]->base]->loot[l]->is_clip()
                        && location[customers.squad[0]->base]->loot[l]->is_good_for_sale())
               {
                  fenceamount += location[customers.squad[0]->base]->loot[l]->get_fencevalue()
                                 * location[customers.squad[0]->base]->loot[l]->get_number();
                  delete_and_remove(location[customers.squad[0]->base]->loot,l);
               }
               else if (c == 'l' && location[customers.squad[0]->base]->loot[l]->is_loot()
                        && location[customers.squad[0]->base]->loot[l]->is_good_for_sale())
               {
                  Loot* a = static_cast<Loot*>(location[customers.squad[0]->base]->loot[l]); //cast -XML
                  if(!a->no_quick_fencing())
                  {
                     fenceamount += location[customers.squad[0]->base]->loot[l]->get_fencevalue()
                                    * location[customers.squad[0]->base]->loot[l]->get_number();
                     delete_and_remove(location[customers.squad[0]->base]->loot,l);
                  }
               }
            }
         }

         if(fenceamount > 0)
         {
            set_color(COLOR_WHITE,COLOR_BLACK,1);
            move(8,1);
            addstr("You add $");
            addstr(tostring(fenceamount).c_str());
            addstr(" to Liberal Funds.");

            refresh();
            getch();

            ledger.add_funds(fenceamount,INCOME_PAWN);
         }
      }
   } while (true);
}