src/lib/update/move_sat.c

Go to the documentation of this file.
00001 /*
00002  *  Empire - A multi-player, client/server Internet based war game.
00003  *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
00004  *                           Ken Stevens, Steve McClure
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  *  ---
00021  *
00022  *  See files README, COPYING and CREDITS in the root of the source
00023  *  tree for related information and legal notices.  It is expected
00024  *  that future projects/authors will amend these files as needed.
00025  *
00026  *  ---
00027  *
00028  *  move_sat.c: Move a satellite to the next point in it's orbit.
00029  * 
00030  *  Known contributors to this file:
00031  *     
00032  */
00033 
00034 #include <config.h>
00035 
00036 #include <math.h>
00037 #include "nsc.h"
00038 #include "path.h"
00039 #include "plane.h"
00040 #include "update.h"
00041 
00042 #ifndef PI
00043 #define PI      3.14159265358979323846
00044 #endif
00045 
00046 void
00047 move_sat(struct plnstr *pp)
00048 {
00049     coord x1, y1, x2, y2;
00050     coord dx, dy;
00051     float newtheta;
00052     struct sctstr sect;
00053 
00054     newtheta = pp->pln_theta + .05;
00055 
00056     if (newtheta >= 1.0) {
00057         newtheta -= 1.0;
00058     }
00059 
00060     x1 = (coord)(2 * pp->pln_theta * WORLD_X);
00061     x1 = xnorm(x1);
00062     y1 = (coord)(sin(6 * PI * pp->pln_theta) * (WORLD_Y / 4));
00063     x2 = (coord)(2 * newtheta * WORLD_X);
00064     x2 = xnorm(x2);
00065     y2 = (coord)(sin(6 * PI * newtheta) * (WORLD_Y / 4));
00066     dx = x1 - pp->pln_x;
00067     dy = y1 - pp->pln_y;
00068     x2 -= dx;
00069     y2 -= dy;
00070 
00071     if ((x2 + y2) & 1) {
00072         x2++;
00073     }
00074 
00075     pp->pln_x = xnorm(x2);
00076     pp->pln_y = ynorm(y2);
00077     pp->pln_theta = newtheta;
00078     getsect(pp->pln_x, pp->pln_y, &sect);
00079     if (sect.sct_own)
00080         if (pp->pln_own != sect.sct_own)
00081             wu(0, sect.sct_own, "%s satellite spotted over %s\n",
00082                cname(pp->pln_own), xyas(pp->pln_x, pp->pln_y,
00083                                         sect.sct_own));
00084     return;
00085 }

Generated on Fri Mar 28 11:01:16 2008 for empserver by  doxygen 1.5.2