[Freeciv-Dev] (PR#13326) Check player_research and player_tech_goal pack
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#13326) Check player_research and player_tech_goal packets |
From: |
"Mateusz Stefek" <mstefek@xxxxxxxxx> |
Date: |
Fri, 24 Jun 2005 03:30:30 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13326 >
The player_research and player_tech_goal packets which comes from client
aren't checked at all. The attached patch fixes the problem
--
mateusz
Index: server/techtools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/techtools.c,v
retrieving revision 1.2
diff -u -r1.2 techtools.c
--- server/techtools.c 24 Jun 2005 10:12:47 -0000 1.2
+++ server/techtools.c 24 Jun 2005 10:28:59 -0000
@@ -659,6 +659,7 @@
}
/****************************************************************************
+ Handle incoming player_research packet. Need to check correctness
Set the player to be researching the given tech.
If there are enough accumulated research points, the tech may be
@@ -666,6 +667,14 @@
****************************************************************************/
void handle_player_research(struct player *pplayer, int tech)
{
+ if (tech != A_FUTURE && !tech_exists(tech)) {
+ return;
+ }
+
+ if (tech != A_FUTURE && get_invention(pplayer, tech) != TECH_REACHABLE) {
+ return;
+ }
+
choose_tech(pplayer, tech);
send_player_info(pplayer, pplayer);
@@ -682,10 +691,19 @@
}
/****************************************************************************
+ Handle incoming player_tech_goal packet
Called from the network or AI code to set the player's tech goal.
****************************************************************************/
void handle_player_tech_goal(struct player *pplayer, int tech_goal)
{
+ if (tech_goal != A_FUTURE && !tech_exists(tech_goal)) {
+ return;
+ }
+
+ if (tech_goal != A_FUTURE && !tech_is_available(pplayer, tech_goal)) {
+ return;
+ }
+
choose_tech_goal(pplayer, tech_goal);
send_player_info(pplayer, pplayer);
- [Freeciv-Dev] (PR#13326) Check player_research and player_tech_goal packets,
Mateusz Stefek <=
|
|