Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where destroyed ships and defense isn't reflected in points #461

Conversation

Newspaperman57
Copy link

Previously the Fleet- and Defense-points reflected the total built ships and defense, regardless of how much was destroyed.
This makes a player look considerably stronger than they are and exposes them through prematurely disabled noob-protection to higher-level players and hinders attacking equally strong players that haven't lost as much yet.

Fleet and Defense-points should therefore reflect the current fleet and defense, which this PR fixes.

I haven't implemented points for when finding ships in expeditions, this should also be added. I might add this later, but for now this isn't a problem on my personal server.

@Newspaperman57
Copy link
Author

Newspaperman57 commented Sep 2, 2021

To aid in retroactively fixing the points on an already running server, i made this SQL to update the stationary ships and defences, list the moving fleets and then you are supposed to manually enter the points for the moving fleets, since they are serialized and not trivial to extract using SQL alone.

Note that it only considers Rocket launchers, and lasers in defense. If anoyone on your server has more than those, you need to add it. My server didn't as it's still pretty young

UPDATE
  xgp_users_statistics as us
  LEFT JOIN (
    SELECT 
      us.user_statistic_user_id as userid,
      SUM(s.ship_small_cargo_ship)*4+
      SUM(s.ship_big_cargo_ship)*12+
      SUM(s.ship_light_fighter)*4+
      SUM(s.ship_heavy_fighter)*10+
      SUM(s.ship_cruiser)*27+
      SUM(s.ship_battleship)*60+
      SUM(s.ship_battlecruiser)*70+
      SUM(s.ship_bomber)*75+
      SUM(s.ship_destroyer)*110+
      SUM(s.ship_deathstar)*9000+
      SUM(s.ship_recycler)*16+
      SUM(s.ship_espionage_probe)*1+
      SUM(s.ship_solar_satellite)*2.5+
      SUM(s.ship_colony_ship)*30 as ships_points,
      
      SUM(d.defense_rocket_launcher)*2+
      SUM(d.defense_light_laser)*2+
      SUM(d.defense_heavy_laser*8) as defense_points
    FROM xgp_users_statistics as us
    LEFT JOIN xgp_planets as p ON p.planet_user_id = us.user_statistic_user_id 
    LEFT JOIN xgp_ships as s ON s.ship_planet_id = p.planet_id
    LEFT JOIN xgp_defenses as d on d.defense_planet_id = p.planet_id
    GROUP BY us.user_statistic_user_id
  ) as ds ON ds.userid = us.user_statistic_user_id
SET
  us.user_statistic_ships_points = ds.ships_points,
  us.user_statistic_defenses_points = ds.defense_points
;
SELECT user.user_id, user.user_name, f.fleet_array FROM xgp_fleets as f
JOIN xgp_users as user ON user.user_id = f.fleet_owner;
;
UPDATE xgp_users_statistics SET user_statistic_ships_points = user_statistic_ships_points + <points for moving fleets> WHERE user_statistic_user_id = <userid>;

@LucasKovacs LucasKovacs changed the base branch from master to xgp-3.3 December 26, 2021 11:02
@LucasKovacs
Copy link
Member

@Newspaperman57 this needs to be adapted to branch xgp3.3

@LucasKovacs
Copy link
Member

LucasKovacs commented Dec 26, 2021

To not wait for the branch rebase and modifications, I've applied the suggested changes making the needed modifications, I'm closing this one. Changes are on commit 6580a92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants