EV-EVA / Ectroverse

Open Source Text based Space Empire Simulator
9 stars 6 forks source link

Let war declaration expire after xdays #21

Closed bertsarens closed 10 years ago

bertsarens commented 11 years ago

Find a way :)

EV-EVA commented 11 years ago

A timer on CMD_RELATION_WAR should do the trick.

Necrolgan commented 10 years ago

Yer, few ways to do that... setting all War Decs to expire after a limited time unless extended is one (prolly easier)... or adding the option to expire each individual decl based on a given input (more databases junk to store...?)

Depends what's really wanted.

Necrolgan commented 10 years ago

Add to config.h

#define AUTOENDWARS (52)

Add to cmdtick.c at begining of cmdTickGenRanks

int wa, wnum;
int *rels;

And further down, just after Empire Lookup.. (line 41)

if( ( wnum = dbEmpireRelsList( b, &rels ) ) < 0 )
    return -3;
wnum <<= 2;
for( wa = 0 ; wa < wnum ; wa += 4 ) {
    if( rels[wa+1] == CMD_RELATION_WAR ) {
        if( (rels[wa] + AUTOENDWARS) <= svTickNum ) {
            cmdExecDelRelation( b, wa );
        } 
    }
}
free( rels );

And that's it... so easy it surprised me.

Necrolgan commented 10 years ago
cmdExecDelRelation( b, wa );

needs to be

cmdExecDelRelation( b, wa/4 );

My mistake, I go up by 4's in the list... so it needs to go back by that factor to cancel the correct number. (or it tries telling it to cancel relation #4 for second relations etc..)

To over-ride the default required time for declerations...

replace in cmdexe.c

if( rel[0]+52 > svTickNum ) 

with

  if( ( rel[0]+52 > svTickNum ) && ( rel[1] != CMD_RELATION_WAR ) )
EV-EVA commented 10 years ago

Implemented, thanks Necro.