Implement /price_list (work in progress), stub for /buy and /sell
remove outdated economic simulation code
remove old values, document
add natural resources to economy
Remove NaturalResources from Place (now in Economy)
find closest site to each chunk
implement natural resources (the distance scale is wrong)
cargo fmt
working distance calculation
this collection of natural resources seem to make sense, too much Wheat though
use natural resources and controlled area to replenish goods
increase the amount of chunks controlled by one guard to 50
add new professions and goods to the list
implement multiple products per worker
remove the old code and rename the new code to the previous name
correctly determine which goods guards will give you access to
correctly estimate the amount of natural resources controlled
adapt to new server API
instrument tooltips
Now I just need to figure out how to store a (reference to) a closure
closures for tooltip content generation
pass site/cave id to the client
Add economic information to the client structure
(not yet exchanged with the server)
Send SiteId to the client, prepare messages for economy request
Make client::sites a HashMap
Specialize the Crafter into Brewer,Bladesmith and Blacksmith
working server request for economic info from within tooltip
fully operational economic tooltips
I need to fix the id clash between caves and towns though
fix overlapping ids between caves and sites
display stock amount
correctly handle invalid (cave) ids in the request
some initial balancing, turn off most info logging
less intrusive way of implementing the dynamic tool tips in map
further tooltip cleanup
further cleanup, dynamic tooltip not fully working as intended
correctly working tooltip visibility logic
cleanup, display labor value
separate economy info request in a separate translation unit
display values as well
nicer display format for economy
add last_exports and coin to the new economy
do not allocate natural resources to Dungeons (making town so much larger)
balancing attempt
print town size statistics
cargo fmt (dead code)
resource tweaks, csv debugging
output a more interesting town (and then all sites)
fix the labor value logic (now we have meaningful prices)
load professions from ron (WIP)
use assets manager in economy
loading professions works
use professions from ron file
fix Labor debug logic
count chunks per type separately
(preparing for better resource control)
better structured resource data
traders, more professions (WIP)
fix exception when starting the simulation
fix replenish function
TODO:
- use area_ratio for resource usage (chunks should be added to stock, ratio on usage?)
- fix trading
documentation clean up
fix merge artifact
Revise trader mechanic
start Coin with a reasonable default
remove the outdated economy code
preserve documentation from removed old structure
output neighboring sites (preparation)
pass list of neighbors to economy
add trade structures
trading stub
Description of purpose by zesterer on Discord
remember prices (needed for planning)
avoid growing the order vector unboundedly
into_iter doesn't clear the Vec, so clear it manually
use drain to process Vecs, avoid clone
fix the test server
implement a test stub (I need to get it faster than 30 seconds to be more useful)
enable info output in test
debug missing and extra goods
use the same logging extension as water, activate feature
update dependencies
determine good prices, good exchange goods
a working set of revisions
a cozy world which economy tests in 2s
first order planning version
fun with package version
buy according to value/priority, not missing amount
introduce min price constant, fix order priority
in depth debugging
with a correct sign the trading plans start to make sense
move the trade planning to a separate function
rename new function
reorganize code into subroutines (much cleaner)
each trading step now has its own function
cut down the number of debugging output
introduce RoadSecurity and Transportation
transport capacity bookkeeping
only plan to pay with valuable goods, you can no longer stockpile unused options
(which interestingly shows a huge impact, to be investigated)
Coin is now listed as a payment (although not used)
proper transportation estimation (although 0)
remove more left overs uncovered by viewing the code in a merge request
use the old default values, handle non-pileable stocks directly before increasing it
(as economy is based on last year's products)
don't order the missing good multiple times
also it uses coin to buy things!
fix warnings and use the transportation from stock again
cargo fmt
prepare evaluation of trade
don't count transportation multiple times
fix merge artifact
operational trade planning
trade itself is still misleading
make clippy happy
clean up
correct labor ratio of merchants (no need to multiply with amount produced)
incomplete merchant labor_value computation
correct last commit
make economy of scale more explicit
make clippy happy (and code cleaner)
more merchant tweaks (more pop=better)
beginning of real trading code
revert the update of dependencies
remove stale comments/unused code
trading implementation complete (but untested)
something is still strange ...
fix sign in trading
another sign fix
some bugfixes and plenty of debugging code
another bug fixed, more to go
fix another invariant (rounding will lead to very small negative value)
introduce Terrain and Territory
fix merge mistakes
2021-03-14 03:18:32 +00:00
|
|
|
use super::{world_msg::EconomyInfo, ClientType, EcsCompPacket, PingMsg};
|
2020-12-13 17:40:15 +00:00
|
|
|
use crate::sync;
|
2020-12-13 17:11:55 +00:00
|
|
|
use common::{
|
|
|
|
character::{self, CharacterItem},
|
2021-02-23 20:29:27 +00:00
|
|
|
comp::{self, invite::InviteKind, item::MaterialStatManifest},
|
2020-07-31 17:16:20 +00:00
|
|
|
outcome::Outcome,
|
2020-07-14 20:11:39 +00:00
|
|
|
recipe::RecipeBook,
|
2020-12-01 00:28:00 +00:00
|
|
|
resources::TimeOfDay,
|
2019-07-21 17:03:06 +00:00
|
|
|
terrain::{Block, TerrainChunk},
|
2021-03-25 04:35:33 +00:00
|
|
|
trade::{PendingTrade, SitePrices, TradeId, TradeResult},
|
2020-12-13 17:40:15 +00:00
|
|
|
uid::Uid,
|
2019-07-21 17:03:06 +00:00
|
|
|
};
|
2019-08-11 20:38:28 +00:00
|
|
|
use hashbrown::HashMap;
|
2020-07-06 14:23:08 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2020-09-06 19:24:52 +00:00
|
|
|
use std::time::Duration;
|
2019-04-10 23:16:29 +00:00
|
|
|
use vek::*;
|
2019-04-19 19:32:47 +00:00
|
|
|
|
2020-10-07 10:31:49 +00:00
|
|
|
///This struct contains all messages the server might send (on different
|
|
|
|
/// streams though)
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub enum ServerMsg {
|
|
|
|
/// Basic info about server, send ONCE, clients need it to Register
|
|
|
|
Info(ServerInfo),
|
|
|
|
/// Initial data package, send BEFORE Register ONCE. Not Register relevant
|
2020-11-14 21:07:07 +00:00
|
|
|
Init(Box<ServerInit>),
|
2020-10-07 10:31:49 +00:00
|
|
|
/// Result to `ClientMsg::Register`. send ONCE
|
|
|
|
RegisterAnswer(ServerRegisterAnswer),
|
|
|
|
///Msg that can be send ALWAYS as soon as client is registered, e.g. `Chat`
|
|
|
|
General(ServerGeneral),
|
|
|
|
Ping(PingMsg),
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
2nd Level Enums
|
|
|
|
*/
|
|
|
|
|
2019-05-08 16:22:52 +00:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub struct ServerInfo {
|
|
|
|
pub name: String,
|
|
|
|
pub description: String,
|
2019-07-21 17:45:31 +00:00
|
|
|
pub git_hash: String,
|
2019-10-18 13:32:26 +00:00
|
|
|
pub git_date: String,
|
2019-12-21 17:02:39 +00:00
|
|
|
pub auth_provider: Option<String>,
|
2019-05-08 16:22:52 +00:00
|
|
|
}
|
|
|
|
|
Redo Network Frontend.
Rather than having a single Stream to handle ALL data, seperate into multiple streams:
- Ping Stream, for seperate PINGS
- Register Stream, only used till the client is registered, then no longer used!
- General Stream, used for msg that can occur always
- NotInGame Stream, used for everything NOT ingame, e.g. Character Screen
- InGame Stream, used for all GAME data, players, terrain, entities, etc...
This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet.
This fixes also the ignoring messages problem we had, as we are not sending data to the register stream!
This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
2020-10-04 18:20:18 +00:00
|
|
|
/// Reponse To ClientType
|
2019-04-22 00:38:29 +00:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
2020-10-05 10:44:33 +00:00
|
|
|
#[allow(clippy::clippy::large_enum_variant)]
|
2020-10-07 10:31:49 +00:00
|
|
|
pub enum ServerInit {
|
Redo Network Frontend.
Rather than having a single Stream to handle ALL data, seperate into multiple streams:
- Ping Stream, for seperate PINGS
- Register Stream, only used till the client is registered, then no longer used!
- General Stream, used for msg that can occur always
- NotInGame Stream, used for everything NOT ingame, e.g. Character Screen
- InGame Stream, used for all GAME data, players, terrain, entities, etc...
This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet.
This fixes also the ignoring messages problem we had, as we are not sending data to the register stream!
This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
2020-10-04 18:20:18 +00:00
|
|
|
TooManyPlayers,
|
|
|
|
GameSync {
|
2019-12-18 05:22:52 +00:00
|
|
|
entity_package: sync::EntityPackage<EcsCompPacket>,
|
2020-12-01 00:28:00 +00:00
|
|
|
time_of_day: TimeOfDay,
|
2020-08-07 01:59:28 +00:00
|
|
|
max_group_size: u32,
|
2020-09-06 19:24:52 +00:00
|
|
|
client_timeout: Duration,
|
2020-10-12 22:06:24 +00:00
|
|
|
world_map: crate::msg::world_msg::WorldMapMsg,
|
2020-07-14 20:11:39 +00:00
|
|
|
recipe_book: RecipeBook,
|
2021-02-23 20:29:27 +00:00
|
|
|
material_stats: MaterialStatManifest,
|
2020-12-13 17:11:55 +00:00
|
|
|
ability_map: comp::item::tool::AbilityMap,
|
2019-04-10 17:23:27 +00:00
|
|
|
},
|
Redo Network Frontend.
Rather than having a single Stream to handle ALL data, seperate into multiple streams:
- Ping Stream, for seperate PINGS
- Register Stream, only used till the client is registered, then no longer used!
- General Stream, used for msg that can occur always
- NotInGame Stream, used for everything NOT ingame, e.g. Character Screen
- InGame Stream, used for all GAME data, players, terrain, entities, etc...
This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet.
This fixes also the ignoring messages problem we had, as we are not sending data to the register stream!
This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
2020-10-04 18:20:18 +00:00
|
|
|
}
|
|
|
|
|
2020-10-07 10:31:49 +00:00
|
|
|
pub type ServerRegisterAnswer = Result<(), RegisterError>;
|
Redo Network Frontend.
Rather than having a single Stream to handle ALL data, seperate into multiple streams:
- Ping Stream, for seperate PINGS
- Register Stream, only used till the client is registered, then no longer used!
- General Stream, used for msg that can occur always
- NotInGame Stream, used for everything NOT ingame, e.g. Character Screen
- InGame Stream, used for all GAME data, players, terrain, entities, etc...
This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet.
This fixes also the ignoring messages problem we had, as we are not sending data to the register stream!
This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
2020-10-04 18:20:18 +00:00
|
|
|
|
2020-10-12 08:18:28 +00:00
|
|
|
/// Messages sent from the server to the client
|
Redo Network Frontend.
Rather than having a single Stream to handle ALL data, seperate into multiple streams:
- Ping Stream, for seperate PINGS
- Register Stream, only used till the client is registered, then no longer used!
- General Stream, used for msg that can occur always
- NotInGame Stream, used for everything NOT ingame, e.g. Character Screen
- InGame Stream, used for all GAME data, players, terrain, entities, etc...
This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet.
This fixes also the ignoring messages problem we had, as we are not sending data to the register stream!
This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
2020-10-04 18:20:18 +00:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
2020-10-12 08:18:28 +00:00
|
|
|
pub enum ServerGeneral {
|
|
|
|
//Character Screen related
|
2020-06-16 01:00:32 +00:00
|
|
|
/// An error occurred while loading character data
|
|
|
|
CharacterDataLoadError(String),
|
2020-05-09 15:41:25 +00:00
|
|
|
/// A list of characters belonging to the a authenticated player was sent
|
|
|
|
CharacterListUpdate(Vec<CharacterItem>),
|
2020-08-25 12:21:25 +00:00
|
|
|
/// An error occurred while creating or deleting a character
|
2020-05-09 15:41:25 +00:00
|
|
|
CharacterActionError(String),
|
2020-11-14 19:32:39 +00:00
|
|
|
/// A new character was created
|
2020-12-13 17:11:55 +00:00
|
|
|
CharacterCreated(character::CharacterId),
|
Redo Network Frontend.
Rather than having a single Stream to handle ALL data, seperate into multiple streams:
- Ping Stream, for seperate PINGS
- Register Stream, only used till the client is registered, then no longer used!
- General Stream, used for msg that can occur always
- NotInGame Stream, used for everything NOT ingame, e.g. Character Screen
- InGame Stream, used for all GAME data, players, terrain, entities, etc...
This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet.
This fixes also the ignoring messages problem we had, as we are not sending data to the register stream!
This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
2020-10-04 18:20:18 +00:00
|
|
|
CharacterSuccess,
|
2020-10-12 08:18:28 +00:00
|
|
|
//Ingame related
|
2020-04-26 17:03:19 +00:00
|
|
|
GroupUpdate(comp::group::ChangeNotification<sync::Uid>),
|
2020-10-12 08:18:28 +00:00
|
|
|
/// Indicate to the client that they are invited to join a group
|
2021-02-12 23:09:18 +00:00
|
|
|
Invite {
|
2020-08-07 01:59:28 +00:00
|
|
|
inviter: sync::Uid,
|
|
|
|
timeout: std::time::Duration,
|
2021-02-11 00:59:14 +00:00
|
|
|
kind: InviteKind,
|
2020-08-07 01:59:28 +00:00
|
|
|
},
|
2020-10-12 08:18:28 +00:00
|
|
|
/// Indicate to the client that their sent invite was not invalid and is
|
|
|
|
/// currently pending
|
2020-08-07 01:59:28 +00:00
|
|
|
InvitePending(sync::Uid),
|
2020-10-12 08:18:28 +00:00
|
|
|
/// Note: this could potentially include all the failure cases such as
|
|
|
|
/// inviting yourself in which case the `InvitePending` message could be
|
|
|
|
/// removed and the client could consider their invite pending until
|
|
|
|
/// they receive this message Indicate to the client the result of their
|
|
|
|
/// invite
|
2020-08-07 01:59:28 +00:00
|
|
|
InviteComplete {
|
|
|
|
target: sync::Uid,
|
|
|
|
answer: InviteAnswer,
|
2021-02-11 00:59:14 +00:00
|
|
|
kind: InviteKind,
|
2020-08-07 01:59:28 +00:00
|
|
|
},
|
2020-02-01 20:39:39 +00:00
|
|
|
/// Trigger cleanup for when the client goes back to the `Registered` state
|
|
|
|
/// from an ingame state
|
Redo Network Frontend.
Rather than having a single Stream to handle ALL data, seperate into multiple streams:
- Ping Stream, for seperate PINGS
- Register Stream, only used till the client is registered, then no longer used!
- General Stream, used for msg that can occur always
- NotInGame Stream, used for everything NOT ingame, e.g. Character Screen
- InGame Stream, used for all GAME data, players, terrain, entities, etc...
This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet.
This fixes also the ignoring messages problem we had, as we are not sending data to the register stream!
This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
2020-10-04 18:20:18 +00:00
|
|
|
ExitInGameSuccess,
|
|
|
|
InventoryUpdate(comp::Inventory, comp::InventoryUpdateEvent),
|
2021-03-11 12:07:03 +00:00
|
|
|
SetViewDistance(u32),
|
|
|
|
Outcomes(Vec<Outcome>),
|
|
|
|
Knockback(Vec3<f32>),
|
|
|
|
// Ingame related AND terrain stream
|
Redo Network Frontend.
Rather than having a single Stream to handle ALL data, seperate into multiple streams:
- Ping Stream, for seperate PINGS
- Register Stream, only used till the client is registered, then no longer used!
- General Stream, used for msg that can occur always
- NotInGame Stream, used for everything NOT ingame, e.g. Character Screen
- InGame Stream, used for all GAME data, players, terrain, entities, etc...
This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet.
This fixes also the ignoring messages problem we had, as we are not sending data to the register stream!
This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
2020-10-04 18:20:18 +00:00
|
|
|
TerrainChunkUpdate {
|
|
|
|
key: Vec2<i32>,
|
|
|
|
chunk: Result<Box<TerrainChunk>, ()>,
|
|
|
|
},
|
|
|
|
TerrainBlockUpdates(HashMap<Vec3<i32>, Block>),
|
2020-10-12 08:18:28 +00:00
|
|
|
// Always possible
|
Redo Network Frontend.
Rather than having a single Stream to handle ALL data, seperate into multiple streams:
- Ping Stream, for seperate PINGS
- Register Stream, only used till the client is registered, then no longer used!
- General Stream, used for msg that can occur always
- NotInGame Stream, used for everything NOT ingame, e.g. Character Screen
- InGame Stream, used for all GAME data, players, terrain, entities, etc...
This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet.
This fixes also the ignoring messages problem we had, as we are not sending data to the register stream!
This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
2020-10-04 18:20:18 +00:00
|
|
|
PlayerListUpdate(PlayerListUpdate),
|
2020-06-02 02:42:26 +00:00
|
|
|
/// A message to go into the client chat box. The client is responsible for
|
2020-06-04 07:11:35 +00:00
|
|
|
/// formatting the message and turning it into a speech bubble.
|
2020-06-02 02:42:26 +00:00
|
|
|
ChatMsg(comp::ChatMsg),
|
2021-02-10 19:42:59 +00:00
|
|
|
ChatMode(comp::ChatMode),
|
2020-06-02 06:11:47 +00:00
|
|
|
SetPlayerEntity(Uid),
|
2020-12-01 00:28:00 +00:00
|
|
|
TimeOfDay(TimeOfDay),
|
2020-03-18 21:00:07 +00:00
|
|
|
EntitySync(sync::EntitySyncPackage),
|
|
|
|
CompSync(sync::CompSyncPackage<EcsCompPacket>),
|
2019-11-24 20:12:03 +00:00
|
|
|
CreateEntity(sync::EntityPackage<EcsCompPacket>),
|
2020-06-02 06:11:47 +00:00
|
|
|
DeleteEntity(Uid),
|
2020-09-14 06:16:09 +00:00
|
|
|
Disconnect(DisconnectReason),
|
2020-05-14 16:56:10 +00:00
|
|
|
/// Send a popup notification such as "Waypoint Saved"
|
|
|
|
Notification(Notification),
|
2021-03-25 04:35:33 +00:00
|
|
|
UpdatePendingTrade(TradeId, PendingTrade, Option<SitePrices>),
|
2021-02-12 20:47:45 +00:00
|
|
|
FinishedTrade(TradeResult),
|
Implement /price_list (work in progress), stub for /buy and /sell
remove outdated economic simulation code
remove old values, document
add natural resources to economy
Remove NaturalResources from Place (now in Economy)
find closest site to each chunk
implement natural resources (the distance scale is wrong)
cargo fmt
working distance calculation
this collection of natural resources seem to make sense, too much Wheat though
use natural resources and controlled area to replenish goods
increase the amount of chunks controlled by one guard to 50
add new professions and goods to the list
implement multiple products per worker
remove the old code and rename the new code to the previous name
correctly determine which goods guards will give you access to
correctly estimate the amount of natural resources controlled
adapt to new server API
instrument tooltips
Now I just need to figure out how to store a (reference to) a closure
closures for tooltip content generation
pass site/cave id to the client
Add economic information to the client structure
(not yet exchanged with the server)
Send SiteId to the client, prepare messages for economy request
Make client::sites a HashMap
Specialize the Crafter into Brewer,Bladesmith and Blacksmith
working server request for economic info from within tooltip
fully operational economic tooltips
I need to fix the id clash between caves and towns though
fix overlapping ids between caves and sites
display stock amount
correctly handle invalid (cave) ids in the request
some initial balancing, turn off most info logging
less intrusive way of implementing the dynamic tool tips in map
further tooltip cleanup
further cleanup, dynamic tooltip not fully working as intended
correctly working tooltip visibility logic
cleanup, display labor value
separate economy info request in a separate translation unit
display values as well
nicer display format for economy
add last_exports and coin to the new economy
do not allocate natural resources to Dungeons (making town so much larger)
balancing attempt
print town size statistics
cargo fmt (dead code)
resource tweaks, csv debugging
output a more interesting town (and then all sites)
fix the labor value logic (now we have meaningful prices)
load professions from ron (WIP)
use assets manager in economy
loading professions works
use professions from ron file
fix Labor debug logic
count chunks per type separately
(preparing for better resource control)
better structured resource data
traders, more professions (WIP)
fix exception when starting the simulation
fix replenish function
TODO:
- use area_ratio for resource usage (chunks should be added to stock, ratio on usage?)
- fix trading
documentation clean up
fix merge artifact
Revise trader mechanic
start Coin with a reasonable default
remove the outdated economy code
preserve documentation from removed old structure
output neighboring sites (preparation)
pass list of neighbors to economy
add trade structures
trading stub
Description of purpose by zesterer on Discord
remember prices (needed for planning)
avoid growing the order vector unboundedly
into_iter doesn't clear the Vec, so clear it manually
use drain to process Vecs, avoid clone
fix the test server
implement a test stub (I need to get it faster than 30 seconds to be more useful)
enable info output in test
debug missing and extra goods
use the same logging extension as water, activate feature
update dependencies
determine good prices, good exchange goods
a working set of revisions
a cozy world which economy tests in 2s
first order planning version
fun with package version
buy according to value/priority, not missing amount
introduce min price constant, fix order priority
in depth debugging
with a correct sign the trading plans start to make sense
move the trade planning to a separate function
rename new function
reorganize code into subroutines (much cleaner)
each trading step now has its own function
cut down the number of debugging output
introduce RoadSecurity and Transportation
transport capacity bookkeeping
only plan to pay with valuable goods, you can no longer stockpile unused options
(which interestingly shows a huge impact, to be investigated)
Coin is now listed as a payment (although not used)
proper transportation estimation (although 0)
remove more left overs uncovered by viewing the code in a merge request
use the old default values, handle non-pileable stocks directly before increasing it
(as economy is based on last year's products)
don't order the missing good multiple times
also it uses coin to buy things!
fix warnings and use the transportation from stock again
cargo fmt
prepare evaluation of trade
don't count transportation multiple times
fix merge artifact
operational trade planning
trade itself is still misleading
make clippy happy
clean up
correct labor ratio of merchants (no need to multiply with amount produced)
incomplete merchant labor_value computation
correct last commit
make economy of scale more explicit
make clippy happy (and code cleaner)
more merchant tweaks (more pop=better)
beginning of real trading code
revert the update of dependencies
remove stale comments/unused code
trading implementation complete (but untested)
something is still strange ...
fix sign in trading
another sign fix
some bugfixes and plenty of debugging code
another bug fixed, more to go
fix another invariant (rounding will lead to very small negative value)
introduce Terrain and Territory
fix merge mistakes
2021-03-14 03:18:32 +00:00
|
|
|
/// Economic information about sites
|
|
|
|
SiteEconomy(EconomyInfo),
|
2020-01-07 06:27:18 +00:00
|
|
|
}
|
|
|
|
|
2020-12-13 17:11:55 +00:00
|
|
|
impl ServerGeneral {
|
|
|
|
pub fn server_msg<S>(chat_type: comp::ChatType<String>, msg: S) -> Self
|
|
|
|
where
|
|
|
|
S: Into<String>,
|
|
|
|
{
|
|
|
|
ServerGeneral::ChatMsg(chat_type.chat_msg(msg))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-07 10:31:49 +00:00
|
|
|
/*
|
|
|
|
end of 2nd level Enums
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// Inform the client of updates to the player list.
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub enum PlayerListUpdate {
|
|
|
|
Init(HashMap<Uid, PlayerInfo>),
|
|
|
|
Add(Uid, PlayerInfo),
|
|
|
|
SelectedCharacter(Uid, CharacterInfo),
|
|
|
|
LevelChange(Uid, u32),
|
|
|
|
Admin(Uid, bool),
|
|
|
|
Remove(Uid),
|
|
|
|
Alias(Uid, String),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub struct PlayerInfo {
|
|
|
|
pub is_admin: bool,
|
|
|
|
pub is_online: bool,
|
|
|
|
pub player_alias: String,
|
|
|
|
pub character: Option<CharacterInfo>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub struct CharacterInfo {
|
|
|
|
pub name: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub enum InviteAnswer {
|
|
|
|
Accepted,
|
|
|
|
Declined,
|
|
|
|
TimedOut,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub enum Notification {
|
|
|
|
WaypointSaved,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub enum DisconnectReason {
|
|
|
|
/// Server shut down
|
|
|
|
Shutdown,
|
|
|
|
/// Client was kicked
|
|
|
|
Kicked(String),
|
|
|
|
}
|
|
|
|
|
2020-01-07 06:27:18 +00:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
|
|
pub enum RegisterError {
|
2020-01-01 20:17:43 +00:00
|
|
|
AuthError(String),
|
2020-07-31 03:34:35 +00:00
|
|
|
Banned(String),
|
2021-03-01 20:29:18 +00:00
|
|
|
Kicked(String),
|
2020-05-11 10:06:53 +00:00
|
|
|
InvalidCharacter,
|
2020-06-24 15:27:18 +00:00
|
|
|
NotOnWhitelist,
|
2019-07-05 12:16:08 +00:00
|
|
|
//TODO: InvalidAlias,
|
2019-07-04 16:14:45 +00:00
|
|
|
}
|
2019-07-17 22:10:42 +00:00
|
|
|
|
2020-10-12 08:18:28 +00:00
|
|
|
impl ServerMsg {
|
|
|
|
pub fn verify(
|
|
|
|
&self,
|
|
|
|
c_type: ClientType,
|
|
|
|
registered: bool,
|
2020-10-30 16:39:53 +00:00
|
|
|
presence: Option<super::PresenceKind>,
|
2020-10-12 08:18:28 +00:00
|
|
|
) -> bool {
|
|
|
|
match self {
|
|
|
|
ServerMsg::Info(_) | ServerMsg::Init(_) | ServerMsg::RegisterAnswer(_) => {
|
2020-10-30 16:39:53 +00:00
|
|
|
!registered && presence.is_none()
|
2020-10-12 08:18:28 +00:00
|
|
|
},
|
|
|
|
ServerMsg::General(g) => {
|
|
|
|
registered
|
|
|
|
&& match g {
|
|
|
|
//Character Screen related
|
|
|
|
ServerGeneral::CharacterDataLoadError(_)
|
|
|
|
| ServerGeneral::CharacterListUpdate(_)
|
2020-11-14 19:32:39 +00:00
|
|
|
| ServerGeneral::CharacterActionError(_)
|
|
|
|
| ServerGeneral::CharacterCreated(_) => {
|
2020-10-30 16:39:53 +00:00
|
|
|
c_type != ClientType::ChatOnly && presence.is_none()
|
2020-10-12 08:18:28 +00:00
|
|
|
},
|
|
|
|
ServerGeneral::CharacterSuccess => {
|
2020-10-30 16:39:53 +00:00
|
|
|
c_type == ClientType::Game && presence.is_none()
|
2020-10-12 08:18:28 +00:00
|
|
|
},
|
|
|
|
//Ingame related
|
|
|
|
ServerGeneral::GroupUpdate(_)
|
2021-02-12 23:09:18 +00:00
|
|
|
| ServerGeneral::Invite { .. }
|
2020-10-12 08:18:28 +00:00
|
|
|
| ServerGeneral::InvitePending(_)
|
|
|
|
| ServerGeneral::InviteComplete { .. }
|
|
|
|
| ServerGeneral::ExitInGameSuccess
|
|
|
|
| ServerGeneral::InventoryUpdate(_, _)
|
|
|
|
| ServerGeneral::TerrainChunkUpdate { .. }
|
|
|
|
| ServerGeneral::TerrainBlockUpdates(_)
|
|
|
|
| ServerGeneral::SetViewDistance(_)
|
|
|
|
| ServerGeneral::Outcomes(_)
|
2021-02-11 04:54:31 +00:00
|
|
|
| ServerGeneral::Knockback(_)
|
2021-03-25 04:35:33 +00:00
|
|
|
| ServerGeneral::UpdatePendingTrade(_, _, _)
|
Implement /price_list (work in progress), stub for /buy and /sell
remove outdated economic simulation code
remove old values, document
add natural resources to economy
Remove NaturalResources from Place (now in Economy)
find closest site to each chunk
implement natural resources (the distance scale is wrong)
cargo fmt
working distance calculation
this collection of natural resources seem to make sense, too much Wheat though
use natural resources and controlled area to replenish goods
increase the amount of chunks controlled by one guard to 50
add new professions and goods to the list
implement multiple products per worker
remove the old code and rename the new code to the previous name
correctly determine which goods guards will give you access to
correctly estimate the amount of natural resources controlled
adapt to new server API
instrument tooltips
Now I just need to figure out how to store a (reference to) a closure
closures for tooltip content generation
pass site/cave id to the client
Add economic information to the client structure
(not yet exchanged with the server)
Send SiteId to the client, prepare messages for economy request
Make client::sites a HashMap
Specialize the Crafter into Brewer,Bladesmith and Blacksmith
working server request for economic info from within tooltip
fully operational economic tooltips
I need to fix the id clash between caves and towns though
fix overlapping ids between caves and sites
display stock amount
correctly handle invalid (cave) ids in the request
some initial balancing, turn off most info logging
less intrusive way of implementing the dynamic tool tips in map
further tooltip cleanup
further cleanup, dynamic tooltip not fully working as intended
correctly working tooltip visibility logic
cleanup, display labor value
separate economy info request in a separate translation unit
display values as well
nicer display format for economy
add last_exports and coin to the new economy
do not allocate natural resources to Dungeons (making town so much larger)
balancing attempt
print town size statistics
cargo fmt (dead code)
resource tweaks, csv debugging
output a more interesting town (and then all sites)
fix the labor value logic (now we have meaningful prices)
load professions from ron (WIP)
use assets manager in economy
loading professions works
use professions from ron file
fix Labor debug logic
count chunks per type separately
(preparing for better resource control)
better structured resource data
traders, more professions (WIP)
fix exception when starting the simulation
fix replenish function
TODO:
- use area_ratio for resource usage (chunks should be added to stock, ratio on usage?)
- fix trading
documentation clean up
fix merge artifact
Revise trader mechanic
start Coin with a reasonable default
remove the outdated economy code
preserve documentation from removed old structure
output neighboring sites (preparation)
pass list of neighbors to economy
add trade structures
trading stub
Description of purpose by zesterer on Discord
remember prices (needed for planning)
avoid growing the order vector unboundedly
into_iter doesn't clear the Vec, so clear it manually
use drain to process Vecs, avoid clone
fix the test server
implement a test stub (I need to get it faster than 30 seconds to be more useful)
enable info output in test
debug missing and extra goods
use the same logging extension as water, activate feature
update dependencies
determine good prices, good exchange goods
a working set of revisions
a cozy world which economy tests in 2s
first order planning version
fun with package version
buy according to value/priority, not missing amount
introduce min price constant, fix order priority
in depth debugging
with a correct sign the trading plans start to make sense
move the trade planning to a separate function
rename new function
reorganize code into subroutines (much cleaner)
each trading step now has its own function
cut down the number of debugging output
introduce RoadSecurity and Transportation
transport capacity bookkeeping
only plan to pay with valuable goods, you can no longer stockpile unused options
(which interestingly shows a huge impact, to be investigated)
Coin is now listed as a payment (although not used)
proper transportation estimation (although 0)
remove more left overs uncovered by viewing the code in a merge request
use the old default values, handle non-pileable stocks directly before increasing it
(as economy is based on last year's products)
don't order the missing good multiple times
also it uses coin to buy things!
fix warnings and use the transportation from stock again
cargo fmt
prepare evaluation of trade
don't count transportation multiple times
fix merge artifact
operational trade planning
trade itself is still misleading
make clippy happy
clean up
correct labor ratio of merchants (no need to multiply with amount produced)
incomplete merchant labor_value computation
correct last commit
make economy of scale more explicit
make clippy happy (and code cleaner)
more merchant tweaks (more pop=better)
beginning of real trading code
revert the update of dependencies
remove stale comments/unused code
trading implementation complete (but untested)
something is still strange ...
fix sign in trading
another sign fix
some bugfixes and plenty of debugging code
another bug fixed, more to go
fix another invariant (rounding will lead to very small negative value)
introduce Terrain and Territory
fix merge mistakes
2021-03-14 03:18:32 +00:00
|
|
|
| ServerGeneral::FinishedTrade(_)
|
|
|
|
| ServerGeneral::SiteEconomy(_) => {
|
2020-10-30 16:39:53 +00:00
|
|
|
c_type == ClientType::Game && presence.is_some()
|
2020-10-12 08:18:28 +00:00
|
|
|
},
|
|
|
|
// Always possible
|
|
|
|
ServerGeneral::PlayerListUpdate(_)
|
|
|
|
| ServerGeneral::ChatMsg(_)
|
2021-02-10 19:42:59 +00:00
|
|
|
| ServerGeneral::ChatMode(_)
|
2020-10-12 08:18:28 +00:00
|
|
|
| ServerGeneral::SetPlayerEntity(_)
|
|
|
|
| ServerGeneral::TimeOfDay(_)
|
|
|
|
| ServerGeneral::EntitySync(_)
|
|
|
|
| ServerGeneral::CompSync(_)
|
|
|
|
| ServerGeneral::CreateEntity(_)
|
|
|
|
| ServerGeneral::DeleteEntity(_)
|
|
|
|
| ServerGeneral::Disconnect(_)
|
|
|
|
| ServerGeneral::Notification(_) => true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ServerMsg::Ping(_) => true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-07 10:31:49 +00:00
|
|
|
impl From<comp::ChatMsg> for ServerGeneral {
|
|
|
|
fn from(v: comp::ChatMsg) -> Self { ServerGeneral::ChatMsg(v) }
|
|
|
|
}
|
|
|
|
|
2021-03-12 11:10:42 +00:00
|
|
|
impl From<ServerInfo> for ServerMsg {
|
|
|
|
fn from(o: ServerInfo) -> ServerMsg { ServerMsg::Info(o) }
|
2020-10-07 10:31:49 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 11:10:42 +00:00
|
|
|
impl From<ServerInit> for ServerMsg {
|
|
|
|
fn from(o: ServerInit) -> ServerMsg { ServerMsg::Init(Box::new(o)) }
|
2020-10-07 10:31:49 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 11:10:42 +00:00
|
|
|
impl From<ServerRegisterAnswer> for ServerMsg {
|
|
|
|
fn from(o: ServerRegisterAnswer) -> ServerMsg { ServerMsg::RegisterAnswer(o) }
|
2020-10-07 10:31:49 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 11:10:42 +00:00
|
|
|
impl From<ServerGeneral> for ServerMsg {
|
|
|
|
fn from(o: ServerGeneral) -> ServerMsg { ServerMsg::General(o) }
|
2020-10-07 10:31:49 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 11:10:42 +00:00
|
|
|
impl From<PingMsg> for ServerMsg {
|
|
|
|
fn from(o: PingMsg) -> ServerMsg { ServerMsg::Ping(o) }
|
2020-06-12 07:43:20 +00:00
|
|
|
}
|