Server Help

ASSS Custom Projects - Simple region tools

Dr Brain - Fri Jul 23, 2004 8:18 am
Post subject: Simple region tools
These are tools to help create single rectangles. Good for testing with regions or very square maps.

numtochar.c:
Code: Show/Hide

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "util.h"
#include "region.h"

int main(int argc, char *argv[])
{
   if (argc == 5)
   {
      rect_t r;
      char out[10];

      r.x = atoi(argv[1]);
      r.y = atoi(argv[2]);
      r.w = atoi(argv[3]);
      r.h = atoi(argv[4]);

      encode_rectangle(out, r);

      printf("x:%i y:%i w:%i h:%i\n", r.x, r.y, r.w, r.h);
      printf("%s\n", out);
      exit(0);
   }
   else
   {
      printf("usage: %s <x> <y> <w> <h>\n", argv[0]);
      exit(1);
   }
}



chartonum.c:
Code: Show/Hide

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "util.h"
#include "region.h"

int main(int argc, char *argv[])
{
   if (argc == 2)
   {
      if (strlen(argv[1]) != 9)
      {
         rect_t r;
         r = decode_rectangle(argv[1]);
         printf("x:%i y:%i w:%i h:%i\n", r.x, r.y, r.w, r.h);
         exit(0);
      }
      else
      {
         printf("Error: bad length.\n");
         exit(1);
      }
   }
   else
   {
      printf("usage: %s <chars>\n", argv[0]);
      exit(1);
   }
}

All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group