00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <config.h>
00035
00036 #include "file.h"
00037 #include "misc.h"
00038 #include "nat.h"
00039 #include "plane.h"
00040 #include "prototypes.h"
00041 #include "ship.h"
00042
00043 int
00044 on_shiplist(short uid, struct shiplist *head)
00045 {
00046 struct shiplist *s;
00047
00048 s = head;
00049 while (s != NULL) {
00050 if (s->uid == uid)
00051 return 1;
00052 s = s->next;
00053 }
00054 return 0;
00055 }
00056
00057 void
00058 add_shiplist(short uid, struct shiplist **head)
00059 {
00060 struct shiplist *s, *s2;
00061
00062 s = *head;
00063 s2 = NULL;
00064
00065 while (s != NULL) {
00066 if (s->uid == uid) {
00067 return;
00068 }
00069 s2 = s;
00070 s = s->next;
00071 }
00072
00073 s = malloc(sizeof(struct shiplist));
00074 if (s2 != NULL)
00075 s2->next = s;
00076 else
00077 *head = s;
00078 s->uid = uid;
00079 s->next = NULL;
00080 }
00081
00082 void
00083 free_shiplist(struct shiplist **head)
00084 {
00085 struct shiplist *s, *s2;
00086
00087 s = *head;
00088
00089 while (s != NULL) {
00090 s2 = s;
00091 s = s->next;
00092 free(s2);
00093 }
00094 *head = NULL;
00095 }
00096
00097 void
00098 print_shiplist(struct shiplist *head)
00099 {
00100 struct shiplist *s;
00101 int first;
00102 struct mchrstr *mp;
00103 struct shpstr ship;
00104
00105 s = head;
00106 first = 1;
00107
00108 while (s != NULL) {
00109 getship(s->uid, &ship);
00110 mp = &mchr[(int)ship.shp_type];
00111 if (first) {
00112 pr(" # player->owner eff type\n");
00113 first = 0;
00114 }
00115 pr("(#%3d) %10.10s %12.12s %s\n", ship.shp_uid,
00116 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
00117 s = s->next;
00118 }
00119 }