diff --git a/include/Screeps/Creep.hpp b/include/Screeps/Creep.hpp index 89ec4a7..7b2484f 100644 --- a/include/Screeps/Creep.hpp +++ b/include/Screeps/Creep.hpp @@ -66,7 +66,7 @@ public: int dismantle(const Structure& target); - int drop(std::string resourceType, std::optional amount); + int drop(const std::string& resourceType, std::optional amount); int generateSafeMode(const StructureController& target); @@ -109,17 +109,17 @@ public: int suicide(); int transfer(const Creep& target, - std::string resourceType, - std::optional amount = std::nullopt); + const std::string& resourceType, + const std::optional& amount = std::nullopt); int transfer(const Structure& target, - std::string resourceType, - std::optional amount = std::nullopt); + const std::string& resourceType, + const std::optional& amount = std::nullopt); int upgradeController(const StructureController& target); int withdraw(const RoomObject& target, - std::string resourceType, - std::optional amount = std::nullopt); + const std::string& resourceType, + const std::optional& amount = std::nullopt); }; } // namespace Screeps diff --git a/include/Screeps/Flag.hpp b/include/Screeps/Flag.hpp index 9dfdd19..f3e563e 100644 --- a/include/Screeps/Flag.hpp +++ b/include/Screeps/Flag.hpp @@ -21,7 +21,7 @@ public: void remove(); - int setColor(int color, std::optional secondaryColor); + int setColor(int color, const std::optional& secondaryColor); int setPosition(int x, int y); int setPosition(const RoomPosition& pos); diff --git a/include/Screeps/Game.hpp b/include/Screeps/Game.hpp index 17b4189..d0ced0f 100644 --- a/include/Screeps/Game.hpp +++ b/include/Screeps/Game.hpp @@ -74,7 +74,7 @@ public: void cpuHalt(); - int cpuSetShardLimits(std::map limits); + int cpuSetShardLimits(const std::map& limits); int cpuUnlock(); diff --git a/include/Screeps/JS.hpp b/include/Screeps/JS.hpp index ce79c24..e0ebc0c 100644 --- a/include/Screeps/JS.hpp +++ b/include/Screeps/JS.hpp @@ -21,7 +21,7 @@ const static Value gGlobal = Value::global(); const static Value gObject = Value::global("Object"); Value getGlobal(char const* name); -Value getGlobal(std::string const& name); +Value getGlobal(const std::string& name); Value getConstant(const std::string& name); bool isInstanceOf(const Value& val, const char* name); diff --git a/include/Screeps/Room.hpp b/include/Screeps/Room.hpp index cbf7c5f..d101fec 100644 --- a/include/Screeps/Room.hpp +++ b/include/Screeps/Room.hpp @@ -35,25 +35,25 @@ public: // std::string serializePath(...) - // ... deserializePath(const std::string path); + // ... deserializePath(const std::string& path); int createConstructionSite(int x, int y, - std::string structureType, - std::optional name = std::nullopt); + const std::string& structureType, + const std::optional& name = std::nullopt); int createConstructionSite(const RoomPosition& pos, - std::string structureType, - std::optional name = std::nullopt); + const std::string& structureType, + const std::optional& name = std::nullopt); int createFlag(int x, int y, - std::optional name = std::nullopt, - std::optional color = std::nullopt, - std::optional secondaryColor = std::nullopt); + const std::optional& name = std::nullopt, + const std::optional& color = std::nullopt, + const std::optional& secondaryColor = std::nullopt); int createFlag(const RoomPosition& pos, - std::optional name = std::nullopt, - std::optional color = std::nullopt, - std::optional secondaryColor = std::nullopt); + const std::optional& name = std::nullopt, + const std::optional& color = std::nullopt, + const std::optional& secondaryColor = std::nullopt); std::vector> find(int type, std::function predicate = {}) const; @@ -87,7 +87,7 @@ public: // ... lookAt(int x, int y); // ... lookAt(const RoomPosition& target); - // ... lookAtArea(int top, int left, int bottom, int right, std::optional asArray = std::nullopt); + // ... lookAtArea(int top, int left, int bottom, int right, const std::optional& asArray = std::nullopt); // ... lookForAt(const std::string& type, int x, int y); // ... lookForAt(const std::string& type, const RoomPosition& target); @@ -97,7 +97,7 @@ public: // int left, // int bottom, // int right, - // std::optional asArray = std::nullopt); + // const std::optional& asArray = std::nullopt); }; } // namespace Screeps diff --git a/include/Screeps/StructureLink.hpp b/include/Screeps/StructureLink.hpp index a11622b..f3e8eee 100644 --- a/include/Screeps/StructureLink.hpp +++ b/include/Screeps/StructureLink.hpp @@ -16,7 +16,7 @@ public: Store store() const; - int transferEnergy(const StructureLink& target, std::optional amount = std::nullopt); + int transferEnergy(const StructureLink& target, const std::optional& amount = std::nullopt); }; } // namespace Screeps diff --git a/include/Screeps/StructureSpawn.hpp b/include/Screeps/StructureSpawn.hpp index ef7b734..062b925 100644 --- a/include/Screeps/StructureSpawn.hpp +++ b/include/Screeps/StructureSpawn.hpp @@ -51,7 +51,7 @@ public: int cancel(); - int setDirections(std::vector directions); + int setDirections(const std::vector& directions); }; } // namespace Screeps diff --git a/include/Screeps/StructureTerminal.hpp b/include/Screeps/StructureTerminal.hpp index 3bc69f7..f5a1a96 100644 --- a/include/Screeps/StructureTerminal.hpp +++ b/include/Screeps/StructureTerminal.hpp @@ -20,7 +20,7 @@ public: int send(const std::string& resourceType, int amount, const std::string& destination, - std::optional description = std::nullopt); + const std::optional& description = std::nullopt); }; } // namespace Screeps diff --git a/src/Creep.cpp b/src/Creep.cpp index d568e56..7ead81b 100644 --- a/src/Creep.cpp +++ b/src/Creep.cpp @@ -125,7 +125,7 @@ int Creep::dismantle(const Structure& target) return value().call("dismantle", target.value()); } -int Creep::drop(std::string resourceType, std::optional amount) +int Creep::drop(const std::string& resourceType, std::optional amount) { if (amount) return value().call("drop", resourceType, *amount); @@ -247,7 +247,9 @@ int Creep::suicide() return value().call("suicide"); } -int Creep::transfer(const Creep& target, std::string resourceType, std::optional amount) +int Creep::transfer(const Creep& target, + const std::string& resourceType, + const std::optional& amount) { if (amount) return value().call("transfer", target.value(), resourceType, *amount); @@ -255,7 +257,9 @@ int Creep::transfer(const Creep& target, std::string resourceType, std::optional return value().call("transfer", target.value(), resourceType); } -int Creep::transfer(const Structure& target, std::string resourceType, std::optional amount) +int Creep::transfer(const Structure& target, + const std::string& resourceType, + const std::optional& amount) { if (amount) return value().call("transfer", target.value(), resourceType, *amount); @@ -268,7 +272,9 @@ int Creep::upgradeController(const StructureController& target) return value().call("upgradeController", target.value()); } -int Creep::withdraw(const RoomObject& target, std::string resourceType, std::optional amount) +int Creep::withdraw(const RoomObject& target, + const std::string& resourceType, + const std::optional& amount) { if (amount) return value().call("withdraw", target.value(), resourceType, *amount); diff --git a/src/Flag.cpp b/src/Flag.cpp index fa03790..231d7a8 100644 --- a/src/Flag.cpp +++ b/src/Flag.cpp @@ -39,7 +39,7 @@ void Flag::remove() value().call("remove"); } -int Flag::setColor(int color, std::optional secondaryColor) +int Flag::setColor(int color, const std::optional& secondaryColor) { if (secondaryColor) return value().call("setColor", color, *secondaryColor); diff --git a/src/JS.cpp b/src/JS.cpp index 93b161d..bb3a05d 100644 --- a/src/JS.cpp +++ b/src/JS.cpp @@ -9,7 +9,7 @@ Value getGlobal(char const* name) return Value::global(name); } -Value getGlobal(std::string const& name) +Value getGlobal(const std::string& name) { return Value::global(name.c_str()); } diff --git a/src/StructureLink.cpp b/src/StructureLink.cpp index 422c018..8089c94 100644 --- a/src/StructureLink.cpp +++ b/src/StructureLink.cpp @@ -18,7 +18,7 @@ Store StructureLink::store() const return Store(value()["store"]); } -int StructureLink::transferEnergy(const StructureLink& target, std::optional amount) +int StructureLink::transferEnergy(const StructureLink& target, const std::optional& amount) { if (amount) return value().call("transferEnergy", target.value(), *amount); diff --git a/src/StructureSpawn.cpp b/src/StructureSpawn.cpp index 0d4a3e0..3009a8f 100644 --- a/src/StructureSpawn.cpp +++ b/src/StructureSpawn.cpp @@ -99,7 +99,7 @@ int StructureSpawn::Spawning::cancel() return value().call("cancel"); } -int StructureSpawn::Spawning::setDirections(std::vector directions) +int StructureSpawn::Spawning::setDirections(const std::vector& directions) { return value().call("setDirections", JS::vectorToJSArray(directions)); } diff --git a/src/StructureTerminal.cpp b/src/StructureTerminal.cpp index 3093f69..2dd067b 100644 --- a/src/StructureTerminal.cpp +++ b/src/StructureTerminal.cpp @@ -19,7 +19,7 @@ Store StructureTerminal::store() const int StructureTerminal::send(const std::string& resourceType, int amount, const std::string& destination, - std::optional description) + const std::optional& description) { if (description) return value().call("send", resourceType, amount, destination, description);