--- deliantra/server/common/anim.C 2007/01/19 17:50:10 1.18 +++ deliantra/server/common/anim.C 2007/02/09 01:52:09 1.20 @@ -53,6 +53,7 @@ if (anim_init) return; + num_animations = 0; /* Make a default. New animations start at one, so if something * thinks it is animated but hasn't set the animation_id properly, @@ -76,15 +77,18 @@ sprintf (buf, "%s/animations", settings.datadir); LOG (llevDebug, "Reading animations from %s...\n", buf); + if ((fp = fopen (buf, "r")) == NULL) { LOG (llevError, "Cannot open animations file %s: %s\n", buf, strerror (errno)); exit (-1); } + while (fgets (buf, MAX_BUF - 1, fp) != NULL) { if (*buf == '#') continue; + /* Kill the newline */ buf[strlen (buf) - 1] = '\0'; if (!strncmp (buf, "anim ", 5)) @@ -94,6 +98,7 @@ LOG (llevError, "Didn't get a mina before %s\n", buf); num_frames = 0; } + num_animations++; animation anim; @@ -106,8 +111,10 @@ else if (!strncmp (buf, "mina", 4)) { animations[num_animations].faces = (uint16 *) malloc (sizeof (uint16) * num_frames); + for (i = 0; i < num_frames; i++) animations[num_animations].faces[i] = faces[i]; + animations[num_animations].num_animations = num_frames; if (num_frames % animations[num_animations].facings) { @@ -131,14 +138,15 @@ LOG (llevDebug, "Could not find face %s for animation %s\n", buf, &animations[num_animations].name); } } + fclose (fp); LOG (llevDebug, "done. got (%d)\n", num_animations); } static int -anim_compare (const animation * a, const animation * b) +anim_compare (const animation *a, const animation *b) { - return strcmp (a->name, b->name); + return std::strcmp (a->name, b->name); } /* Tries to find the animation id that matches name. Returns an integer match @@ -202,7 +210,7 @@ */ max_state = NUM_ANIMATIONS (op) / NUM_FACINGS (op); base_state = 0; - /* at least in the older aniamtions that used is_turning, the first half + /* at least in the older animations that used is_turning, the first half * of the animations were left facing, the second half right facing. * Note in old the is_turning, it was set so that the animation for a monster * was always towards the enemy - now it is whatever direction the monster @@ -239,13 +247,12 @@ if (op->face == blank_face) op->invisible = 1; - /* This block covers monsters (eg, pixies) which are supposed to * cycle from visible to invisible and back to being visible. * as such, disable it for players, as then players would become * visible. */ - else if (op->type != PLAYER && QUERY_FLAG ((&op->arch->clone), FLAG_ALIVE)) + else if (op->type != PLAYER && op->arch->clone.flag [FLAG_ALIVE]) { if (op->face->number == 0) {