[Freeciv-Dev] Re: dynamic timeout (PR#1356)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sat, Mar 30, 2002 at 09:25:43PM -0800, Mike Kaufman wrote:
> With help from Per, here is the next go around of the magically
> increasing timer. How it works:
>
> set timeout <timeout>
>
> people should hopefully be familiar with that part. The new part:
>
> timeoutincrease <turn> <turninc> <value> <valuemult>
> Description:
> Every <turn> turns, add <value> to timeout timer,
> then add <turninc> to <turn> and multiply <value>
> by <valuemult>.
Can you also post a formula?
> sound complicated? yes it is, but with about a minute of thought you'll
> see how powerful and flexible it is.
>
> I'm not terribly good at parsing text, so please try it out and try to
> break it.
> +/**************************************************************************
> + Set timeout options.
> +**************************************************************************/
> +static void timeout_command(struct connection *caller, char *str)
> +{
> + char buf[MAX_LEN_CONSOLE_LINE];
> + char *bptr = buf, *arg[4] = {NULL, NULL, NULL, NULL};
> + int i = 0, noargs = 0, val[4];
> + int *timeouts[4];
> +
> + timeouts[0] = &game.timeoutint;
> + timeouts[1] = &game.timeoutintinc;
> + timeouts[2] = &game.timeoutinc;
> + timeouts[3] = &game.timeoutincmult;
> +
> + assert(str != NULL);
> +
> + sz_strlcpy(buf, str);
> + remove_trailing_spaces(buf);
> + while(*bptr != '\0' && i < 4) {
> + /* skip intervening whitespace */
> + while(*bptr == ' ' || *bptr == '\t') {
> + bptr++;
> + }
> +
> + arg[i++] = bptr;
> +
> + /* skip arg */
> + while(*bptr != ' ' && *bptr != '\t' && *bptr != '\0') {
> + bptr++;
> + }
> +
> + if (*bptr == '\0') {
> + break;
> + } else {
> + *(bptr++) = '\0';
> + }
> + }
This could be replaced with strtok. This may also a good time to
introduce a split method.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Any sufficiently advanced technology is indistinguishable from magic."
-- Arthur C. Clarke
- [Freeciv-Dev] Re: dynamic timeout (PR#1356), Gregory Berkolaiko, 2002/04/01
- [Freeciv-Dev] Re: dynamic timeout (PR#1356),
Raimar Falke <=
- [Freeciv-Dev] Re: dynamic timeout (PR#1356), Mike Kaufman, 2002/04/03
- [Freeciv-Dev] Re: dynamic timeout (PR#1356), Raimar Falke, 2002/04/07
- [Freeciv-Dev] Re: dynamic timeout (PR#1356), Mike Kaufman, 2002/04/07
- [Freeciv-Dev] Re: dynamic timeout (PR#1356), Raimar Falke, 2002/04/07
- [Freeciv-Dev] Re: dynamic timeout (PR#1356), Mike Kaufman, 2002/04/07
- [Freeciv-Dev] Re: dynamic timeout (PR#1356), Raimar Falke, 2002/04/07
|
|