Update of /cvsroot/netrek/server/Vanilla/ntserv In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3938/ntserv Modified Files: util.c commands.c daemonII.c ntscmds.c Log Message: factorise team name Index: commands.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/commands.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- commands.c 22 Apr 2006 11:31:53 -0000 1.3 +++ commands.c 23 Apr 2006 10:39:10 -0000 1.4 @@ -77,8 +77,6 @@ #endif #if defined (TRIPLE_PLANET_MAYHEM) -char *teamNames[9] = {" ", "Federation", "Romulans", " ", "Klingons", - " ", " ", " ", "Orions"}; int do_balance(); int do_triple_planet_mayhem(); #endif @@ -622,7 +620,7 @@ struct player *k = &players[p_no]; pmessage(0, MALL, "GOD->ALL", "Balance: %16s (%c%c) is to join the %s", - k->p_name, teamlet[k->p_team], shipnos[p_no], teamNames[ours] ); + k->p_name, teamlet[k->p_team], shipnos[p_no], team_name(ours)); } /* @@ -638,15 +636,15 @@ if ( k->p_team != ours ) { pmessage(k->p_no, MINDIV, addr_mess(k->p_no,MINDIV), - "%s: please SWAP SIDES to the %s", k->p_name, teamNames[ours] ); + "%s: please SWAP SIDES to the %s", k->p_name, team_name(ours)); } else { pmessage(k->p_no, MINDIV, addr_mess(k->p_no,MINDIV), - "%s: please remain with the %s", k->p_name, teamNames[ours] ); + "%s: please remain with the %s", k->p_name, team_name(ours)); } printf("Balance: %16s (%s) is to join the %s\n", - k->p_name, k->p_mapchars, teamNames[ours]); + k->p_name, k->p_mapchars, team_name(ours)); /* cope with a balance during INL pre-game, if we don't shift players who are on the QU_HOME or QU_AWAY queues then the queue masks will force @@ -912,12 +910,12 @@ /* advise all of resultant team mix difference */ pmessage ( 0, MALL, "GOD->ALL", "The %s total rating will be %.2f", - teamNames[one], + team_name(one), (float) ( best.one / 100.0 ) ); pmessage ( 0, MALL, "GOD->ALL", "The %s total rating will be %.2f", - teamNames[two], + team_name(two), (float) ( best.two / 100.0 ) ); return 0; @@ -1262,13 +1260,11 @@ int who,type; { static char addrbuf[10]; - char* team_names[MAXTEAM+1] = { "", "FED", "ROM", "", "KLI", - "", "", "", "ORI" }; if (type == MALL) sprintf(addrbuf,"%s->ALL", myname); else if (type == MTEAM) - sprintf(addrbuf,"%s->%3s", myname, team_names[who]); + sprintf(addrbuf,"%s->%3s", myname, team_code(who)); else /* Assume MINDIV */ sprintf(addrbuf, "%s->%2s", myname, players[who].p_mapchars); @@ -1618,8 +1614,6 @@ char *comm; struct message *mess; { - char *teamNames[9] = {" ", "Federation", "Romulans", " ", "Klingons", - " ", " ", " ", "Orions"}; int who; int t; char *addr; @@ -1632,7 +1626,7 @@ if (t>MAXTEAM) { pmessage(who, MINDIV, addr, "No one is considering surrender now. Go take some planets."); } else { - pmessage(who, MINDIV, addr, "The %s have %d minutes left before they surrender.", teamNames[t],teams[t].s_surrender); + pmessage(who, MINDIV, addr, "The %s have %d minutes left before they surrender.", team_name(t), teams[t].s_surrender); } } Index: ntscmds.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/ntscmds.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ntscmds.c 10 Apr 2006 11:57:00 -0000 1.6 +++ ntscmds.c 23 Apr 2006 10:39:10 -0000 1.7 @@ -47,8 +47,6 @@ #endif #if defined (TRIPLE_PLANET_MAYHEM) -char *teamNames[9] = {" ", "Federation", "Romulans", " ", "Klingons", - " ", " ", " ", "Orions"}; void do_balance(void); void do_triple_planet_mayhem(void); #endif @@ -608,8 +606,6 @@ /* ARGSUSED */ void do_time_msg(char *comm, struct message *mess) { - char *teamNames[9] = {" ", "Federation", "Romulans", " ", "Klingons", - " ", " ", " ", "Orions"}; int who; int t; char *addr; @@ -622,7 +618,7 @@ if (t>MAXTEAM) { pmessage(who, MINDIV, addr, "No one is considering surrender now. Go take some planets."); } else { - pmessage(who, MINDIV, addr, "The %s have %d minutes left before they surrender.", teamNames[t],teams[t].s_surrender); + pmessage(who, MINDIV, addr, "The %s have %d minutes left before they surrender.", team_name(t), teams[t].s_surrender); } } @@ -730,7 +726,7 @@ "Balance: %16s (slot %c, rating %.2f) is to join the %s", k->p_name, shipnos[p_no], (float) ( p_value / 100.0 ), - teamNames[ours] ); + team_name(ours)); /* annoying compiler warning */ if (theirs) ; @@ -748,15 +744,15 @@ if ( k->p_team != ours ) { pmessage(k->p_no, MINDIV, addr_mess(k->p_no,MINDIV), - "%s: please SWAP SIDES to the --> %s <--", k->p_name, teamNames[ours] ); + "%s: please SWAP SIDES to the --> %s <--", k->p_name, team_name(ours)); } else { pmessage(k->p_no, MINDIV, addr_mess(k->p_no,MINDIV), - "%s: please remain with the --> %s <--", k->p_name, teamNames[ours] ); + "%s: please remain with the --> %s <--", k->p_name, team_name(ours)); } printf("Balance: %16s (%s) is to join the %s\n", - k->p_name, k->p_mapchars, teamNames[ours]); + k->p_name, k->p_mapchars, team_name(ours)); /* cope with a balance during INL pre-game, if we don't shift players who are on the QU_HOME or QU_AWAY queues then the queue masks will force @@ -1044,8 +1040,8 @@ { pmessage ( 0, MALL, addr_mess(0, MALL), "No balance performed, this is the best: %-3s %.2f, %-3s %.2f", - teamNames[one], (float) ( best.one / 100.0 ), - teamNames[two], (float) ( best.two / 100.0 ) ); + team_name(one), (float) ( best.one / 100.0 ), + team_name(two), (float) ( best.two / 100.0 ) ); } } Index: util.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/util.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- util.c 10 Apr 2006 10:41:08 -0000 1.3 +++ util.c 23 Apr 2006 10:39:10 -0000 1.4 @@ -126,3 +126,44 @@ #endif return -1; } + +char *team_name(int team) { + char *array[MAXTEAM+1] = { "0", "Federation", "Romulans", "3", "Klingons", + "5", "6", "7", "Orions" }; + return array[team]; +} + +char *team_verb(int team) { + char *array[MAXTEAM+1] = { "0", "has", "have", "3", "have", + "5", "6", "7", "have" }; + return array[team]; +} + +char *team_code(int team) { + char *array[MAXTEAM+1] = { "0", "FED", "ROM", "3", "KLI", + "5", "6", "7", "ORI" }; + return array[team]; +} + +int team_find(char *name) +{ + if (!strncasecmp(name,team_name(FED),strlen(name))) return FED; + if (!strncasecmp(name,team_name(ROM),strlen(name))) return ROM; + if (!strncasecmp(name,team_name(KLI),strlen(name))) return KLI; + if (!strncasecmp(name,team_name(ORI),strlen(name))) return ORI; + return 0; +} + +void orbit_release_by_planet(struct planet *pl) { + int i; + for (i=0; i<MAXPLAYER; i++) { + struct player *me = &players[i]; + if (me->p_status & PFREE) continue; + if (me->p_flags & PFOBSERV) continue; + if (me->p_flags & PFORBIT) { + if (me->p_planet == pl->pl_no) { + me->p_flags &= ~(PFBOMB | PFORBIT | PFBEAMUP | PFBEAMDOWN); + } + } + } +} Index: daemonII.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/ntserv/daemonII.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- daemonII.c 22 Apr 2006 02:16:46 -0000 1.8 +++ daemonII.c 23 Apr 2006 10:39:10 -0000 1.9 @@ -121,7 +121,6 @@ static void doResources(void); /* static void doRotateGalaxy(void); */ static void signal_servers(void); -/* static void message_flag(struct message *cur, char *address); */ /* external scope prototypes */ extern void pinit(void); @@ -139,10 +138,6 @@ static int ticks = 0; static int tourntimestamp = 0; /* ticks since last Tmode 8/2/91 TC */ -char *teamNames[9] = {" ", "Federation", "Romulans", " ", "Klingons", - " ", " ", " ", "Orions"}; -char *teamVerbage[9] = {" ", "has", "have", " ", "have", " ", " ", " ", "have"}; - static int tcount[MAXTEAM + 1]; u_char getbearing(); @@ -2516,7 +2511,7 @@ pmessage(0, MALL, " ", " "); pmessage(0, MALL, "GOD->ALL", "The %s %s surrendered.", - teamNames[t], teamVerbage[t]); + team_name(t), team_verb(t)); pmessage(0, MALL, " ", " "); surrenderMessage(t); @@ -2563,7 +2558,7 @@ if ((teams[t].s_surrender % 5) == 0) { pmessage(0, MALL, " ", " "); pmessage(0, MALL, "GOD->ALL", "The %s %s %d minutes remaining.", - teamNames[t], teamVerbage[t], + team_name(t), team_verb(t), teams[t].s_surrender); pmessage(0, MALL, "GOD->ALL", "%d planets will sustain the empire. %d suspends countdown.", @@ -3639,7 +3634,7 @@ pmessage(0, MALL, " ", " "); pmessage(0, MALL, "GOD->ALL", "The %s %s %d minutes before the empire collapses.", - teamNames[loser], teamVerbage[loser], + team_name(loser), team_verb(loser), binconfirm ? SURRLENGTH : SURRLENGTH*2/3); pmessage(0, MALL, "GOD->ALL", "%d planets are needed to sustain the empire.", @@ -3766,7 +3761,7 @@ pmessage(0, MALL, " ", " "); pmessage(0, MALL, "GOD->ALL", "The %s %s prevented collapse of the empire.", - teamNames[winner->p_team], teamVerbage[winner->p_team]); + team_name(winner->p_team), team_verb(winner->p_team)); pmessage(0, MALL, " ", " "); teams[winner->p_team].s_surrender = 0; /* stop the clock */ } @@ -4124,20 +4119,10 @@ strcat(buf, ctime(&curtime)); fprintf(conqfile," %s\n",buf); - sprintf(buf, "The %s %s surrendered.", teamNames[loser], - teamVerbage[loser]); + sprintf(buf, "The %s %s surrendered.", team_name(loser), + team_verb(loser)); fprintf(conqfile, " %s\n", buf); -/* sprintf(buf, "The %s:", teamNames[winner]); - pmessage(0, MALL | MGENO, " ",buf); - fprintf(conqfile, " %s\n", buf); - displayBest(conqfile, winner, KGENOCIDE);*/ -/* sprintf(buf, "The %s:", teamNames[loser]); - pmessage(0, MALL | MGENO, " ",buf); - fprintf(conqfile, " %s\n", buf); - displayBest(conqfile, loser, KGENOCIDE); - pmessage(0, MALL | MGENO, " ", - "***********************************************************");*/ fprintf(conqfile, "\n"); if (conqfile != stderr) fclose(conqfile); } @@ -4159,16 +4144,16 @@ pmessage(0, MALL | MGENO, " ","%s", "***********************************************************"); - sprintf(buf, "The %s %s been genocided by the %s.", teamNames[loser], - teamVerbage[loser], teamNames[winner]); + sprintf(buf, "The %s %s been genocided by the %s.", team_name(loser), + team_verb(loser), team_name(winner)); pmessage(0, MALL | MGENO, " ","%s",buf); fprintf(conqfile, " %s\n", buf); - sprintf(buf, "The %s:", teamNames[winner]); + sprintf(buf, "The %s:", team_name(winner)); pmessage(0, MALL | MGENO, " ","%s",buf); fprintf(conqfile, " %s\n", buf); displayBest(conqfile, winner, KGENOCIDE); - sprintf(buf, "The %s:", teamNames[loser]); + sprintf(buf, "The %s:", team_name(loser)); pmessage(0, MALL | MGENO, " ","%s",buf); fprintf(conqfile, " %s\n", buf); displayBest(conqfile, loser, KGENOCIDE); @@ -4195,10 +4180,10 @@ pmessage(0, MALL | MCONQ, " ","%s", "***********************************************************"); - sprintf(buf, "The galaxy has been conquered by the %s:", teamNames[winner]); + sprintf(buf, "The galaxy has been conquered by the %s:", team_name(winner)); pmessage(0, MALL | MCONQ, " ","%s",buf); fprintf(conqfile, " %s\n", buf); - sprintf(buf, "The %s:", teamNames[winner]); + sprintf(buf, "The %s:", team_name(winner)); pmessage(0, MALL | MCONQ, " ","%s",buf); fprintf(conqfile, " %s\n", buf); displayBest(conqfile, winner, KWINNER);