ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_misc.C
(Generate patch)

Comparing deliantra/server/server/c_misc.C (file contents):
Revision 1.39 by root, Mon Jan 29 14:46:01 2007 UTC vs.
Revision 1.46 by pippijn, Thu Mar 1 13:18:37 2007 UTC

69{ 69{
70 display_motd (op); 70 display_motd (op);
71 return 1; 71 return 1;
72} 72}
73 73
74int
75command_bug (object *op, char *params)
76{
77 char buf[MAX_BUF];
78
79 if (params == NULL)
80 {
81 new_draw_info (NDI_UNIQUE, 0, op, "what bugs?");
82 return 1;
83 }
84 strcpy (buf, op->name);
85 strcat (buf, " bug-reports: ");
86 strncat (buf, ++params, MAX_BUF - strlen (buf));
87 buf[MAX_BUF - 1] = '\0';
88 bug_report (buf);
89 LOG (llevError, "%s\n", buf);
90 new_draw_info (NDI_ALL | NDI_UNIQUE, 1, NULL, buf);
91 new_draw_info (NDI_UNIQUE, 0, op, "OK, thanks!");
92 return 1;
93}
94
95/* 74/*
96 * Pretty much identical to current map_info, but on a bigger scale 75 * Pretty much identical to current map_info, but on a bigger scale
97 * This function returns the name of the players current region, and 76 * This function returns the name of the players current region, and
98 * a description of it. It is there merely for flavour text. 77 * a description of it. It is there merely for flavour text.
99 */ 78 */
100void 79void
101current_region_info (object *op) 80current_region_info (object *op)
102{ 81{
103 if (region *reg = op->region ()) 82 if (region *reg = op->region ())
104 new_draw_info_format (NDI_UNIQUE, 0, op, "You are in %s.\n%s", reg->longname, reg->msg); 83 new_draw_info_format (NDI_UNIQUE, 0, op, "You are %s.\n%s", &reg->longname, &reg->msg);
105} 84}
106 85
107void 86void
108current_map_info (object *op) 87current_map_info (object *op)
109{ 88{
110 maptile *m = op->map; 89 maptile *m = op->map;
111 90
112 if (!m) 91 if (!m)
113 return; 92 return;
114 93
115 new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", &m->name, &m->path, &op->region ()->name); 94 new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) %s", &m->name, &m->path, &op->region ()->longname);
116 95
117 if (QUERY_FLAG (op, FLAG_WIZ)) 96 if (QUERY_FLAG (op, FLAG_WIZ))
118 new_draw_info_format (NDI_UNIQUE, 0, op, 97 new_draw_info_format (NDI_UNIQUE, 0, op,
119 "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", 98 "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld",
120 m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); 99 m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout);
144 /* 123 /*
145 * reset the counter on the region, then use it to store the number of 124 * reset the counter on the region, then use it to store the number of
146 * players there. 125 * players there.
147 * I don't know how thread-safe this would be, I suspect not very.... 126 * I don't know how thread-safe this would be, I suspect not very....
148 */ 127 */
149 for (region *reg = first_region; reg; reg = reg->next) 128 for_all_regions (rgn)
150 reg->counter = 0; 129 rgn->counter = 0;
151 130
152 for_all_players (pl) 131 for_all_players (pl)
153 if (pl->ob->map) 132 if (pl->ob->map)
154 ++pl->ob->region ()->counter; 133 ++pl->ob->region ()->counter;
155 134
156 /* we only want to print out by places with a 'longname' field... */ 135 /* we only want to print out by places with a 'longname' field... */
157 for (region *reg = first_region; reg; reg = reg->next) 136 for_all_regions (rgn)
158 { 137 {
159 if (reg->longname == NULL && reg->counter > 0) 138 if (!rgn->longname && rgn->counter > 0)
160 { 139 {
161 if (reg->parent) 140 if (rgn->parent)
162 { 141 {
163 reg->parent->counter += reg->counter; 142 rgn->parent->counter += rgn->counter;
164 reg->counter = 0; 143 rgn->counter = 0;
165 } 144 }
166 else /*uh oh, we shouldn't be here. */ 145 else /*uh oh, we shouldn't be here. */
167 LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", &reg->name); 146 LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", &rgn->name);
168 } 147 }
169 } 148 }
170 149
171 new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:"); 150 new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:");
172 151
173 for (region *reg = first_region; reg; reg = reg->next) 152 for_all_regions (rgn)
174 if (reg->counter) 153 if (rgn->counter)
175 new_draw_info_format (NDI_UNIQUE, 0, op, "%u players in %s", reg->counter, reg->longname); 154 new_draw_info_format (NDI_UNIQUE, 0, op, "%u players %s", rgn->counter, &rgn->longname);
176 155
177 return 1; 156 return 1;
178} 157}
179 158
180typedef struct 159typedef struct
343 case SKY_BLIZZARD: 322 case SKY_BLIZZARD:
344 new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); 323 new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!");
345 break; 324 break;
346 } 325 }
347#endif 326#endif
348 return 1;
349}
350
351int
352command_archs (object *op, char *params)
353{
354 arch_info (op);
355 return 1; 327 return 1;
356} 328}
357 329
358int 330int
359command_hiscore (object *op, char *params) 331command_hiscore (object *op, char *params)
808 780
809 if (!(dirp = opendir (filename))) 781 if (!(dirp = opendir (filename)))
810 return; 782 return;
811 783
812 line[0] = '\0'; 784 line[0] = '\0';
813 while (de = readdir (dirp)) 785 while ((de = readdir (dirp)))
814 { 786 {
815 namelen = strlen (de->d_name); 787 namelen = strlen (de->d_name);
816 if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) 788 if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.'))
817 continue; 789 continue;
818 linelen += namelen + 1; 790 linelen += namelen + 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines