Update of /cvsroot/gcblue/gcb_wx/src/ai
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28827/src/ai
Modified Files:
Brain.cpp Nav.cpp
Log Message:
0.7.2 pre-release test build, added waypoints to client display, fixed multiplayer message overload bug, added better throttling for bad multiplayer connections
Index: Brain.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/ai/Brain.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Brain.cpp 5 May 2005 02:14:45 -0000 1.8
--- Brain.cpp 29 Jul 2005 02:35:52 -0000 1.9
***************
*** 79,82 ****
--- 79,88 ----
}
+ // update waypoints if nav task exists
+ if (ai::Nav* nav = GetNavTask())
+ {
+ nav->operator<<(stream);
+ }
+
return stream;
}
***************
*** 106,109 ****
--- 112,121 ----
}
+ // update waypoints if nav task exists
+ if (ai::Nav* nav = GetNavTask())
+ {
+ nav->operator>>(stream);
+ }
+
return stream;
}
***************
*** 160,163 ****
--- 172,183 ----
/**
+ * For multiplayer, call when task is added or deleted, or nav task waypoints have changed
+ */
+ void Brain::SetNewCommand()
+ {
+ hasNewCommand = true;
+ }
+
+ /**
* Set target id for platform
*/
Index: Nav.cpp
===================================================================
RCS file: /cvsroot/gcblue/gcb_wx/src/ai/Nav.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Nav.cpp 1 Jun 2005 00:13:28 -0000 1.2
--- Nav.cpp 29 Jul 2005 02:35:52 -0000 1.3
***************
*** 27,33 ****
--- 27,37 ----
#include "ai/Nav.h"
+ #include "ai/Brain.h"
#include "scriptinterface/tcPlatformInterface.h"
#include "simmath.h"
+ #include "common/tcStream.h"
+ #include "common/tcObjStream.h"
+
#ifdef _DEBUG
#define new DEBUG_NEW
***************
*** 37,40 ****
--- 41,91 ----
using scriptinterface::tcPlatformInterface;
+
+ /**
+ * Saves state to command stream
+ * Used to save waypoints for client to display
+ */
+ tcCommandStream& Nav::operator>>(tcCommandStream& stream)
+ {
+ unsigned char nWaypoints = waypoints.size();
+ stream << nWaypoints;
+
+ for (unsigned char n=0; n<nWaypoints; n++)
+ {
+ stream << waypoints[n].mfLon_rad;
+ stream << waypoints[n].mfLat_rad;
+ stream << waypoints[n].mfAlt_m;
+ }
+
+ return stream;
+ }
+
+ /**
+ * Loads state to command stream
+ * Used to load waypoints for client to display
+ */
+ tcCommandStream& Nav::operator<<(tcCommandStream& stream)
+ {
+ waypoints.clear();
+
+ unsigned char nWaypoints;
+ stream >> nWaypoints;
+
+ for (unsigned char n=0; n<nWaypoints; n++)
+ {
+ float lon_rad, lat_rad, alt_m;
+
+ stream >> lon_rad;
+ stream >> lat_rad;
+ stream >> alt_m;
+
+ GeoPoint waypoint;
+ waypoint.Set(lon_rad, lat_rad, alt_m);
+ waypoints.push_back(waypoint);
+ }
+
+ return stream;
+ }
+
void Nav::AddWaypoint(double lon_rad, double lat_rad, float alt_m)
{
***************
*** 43,51 ****
--- 94,111 ----
waypoints.push_back(waypoint);
+
+ platform->GetBrain()->SetNewCommand();
}
void Nav::ClearWaypoints()
{
+ if (waypoints.size())
+ {
+ platform->GetBrain()->SetNewCommand();
+ }
+
waypoints.clear();
+
+
}
|