diff --git a/cube.h b/cube.h index 381b140..bd407a9 100644 --- a/cube.h +++ b/cube.h @@ -47,6 +47,7 @@ #include #include #include +#include #ifdef WIN32 #define WIN32_LEAN_AND_MEAN diff --git a/iengine.h b/iengine.h index d7dd076..17ea7dd 100644 --- a/iengine.h +++ b/iengine.h @@ -2145,9 +2145,9 @@ extern int showmat; /**< treat as bool, determines whether material outlines are * * @param name a C string with the name of the material to look up * - * @return an integer corresponding to the bitmask value of the material + * @return an integer corresponding to the bitmask value of the material or std::nullopt if it fails */ -extern int findmaterial(const char *name); +extern std::optional findmaterial(const char *name); // octaworld diff --git a/slot.h b/slot.h index f373dad..6819faf 100644 --- a/slot.h +++ b/slot.h @@ -112,7 +112,7 @@ struct Slot virtual VSlot &emptyvslot(); - virtual int cancombine(int type)const; + virtual std::optional cancombine(int type) const; virtual bool shouldpremul(int) const { return false; @@ -122,14 +122,14 @@ struct Slot * @brief Attempts to find a tex with index type. * * Searches for a tex with the type passed, searching only for the part of the - * sts vector after `last`. If none is found, returns -1. + * sts vector after `last`. * * @param type the type to seach for * @param last the last index to not look at * - * @return the index where the type was found + * @return the index where the type was found, else std::nullopt. */ - int findtextype(int type, int last = -1) const; + std::optional findtextype(int type, int last = -1) const; void load(int index, Slot::Tex &t); void load(); @@ -265,7 +265,7 @@ struct DecalSlot final : Slot, VSlot return *this; } - int cancombine(int type) const override final; + std::optional cancombine(int type) const override final; bool shouldpremul(int type) const override final; void reset() diff --git a/sound.h b/sound.h index 582f26b..79376ff 100644 --- a/sound.h +++ b/sound.h @@ -52,6 +52,7 @@ class SoundEngine /** * @brief Plays a sound with the given attributes. + * * * @param n index of the sound to play * @param loc world location to play at @@ -62,8 +63,10 @@ class SoundEngine * @param chanid music channel index to use * @param radius distance over which sound is audible (in size 0 cubes) * @param expire maximum time before the sound stops playing + * + * @return the channel id or std::nullopt in case of failure. */ - int playsound(int n, const vec *loc = nullptr, extentity *ent = nullptr, int flags = 0, int loops = 0, int fade = 0, int chanid = -1, int radius = 0, int expire = -1); + std::optional playsound(int n, const vec *loc = nullptr, extentity *ent = nullptr, int flags = 0, int loops = 0, int fade = 0, int chanid = -1, int radius = 0, int expire = -1); /** * @brief Stops playing a sound of index n in the specificied channel. @@ -101,8 +104,10 @@ class SoundEngine * @param chanid music channel index to use * @param radius distance over which sound is audible (in size 0 cubes) * @param expire maximum time before the sound stops playing + * + * @return the channel id where the song gets played or std::nullopt if it fails */ - int playsoundname(const char *s, const vec *loc, int vol, int flags, int loops, int fade, int chanid, int radius, int expire); + std::optional playsoundname(const char *s, const vec *loc, int vol, int flags, int loops, int fade, int chanid, int radius, int expire); /** * @brief Starts SDL_Mixer and initializes startup sound channels. @@ -415,7 +420,7 @@ class SoundEngine std::vector configs; const char *dir; SoundType(const char *dir, SoundEngine& p); - int findsound(const char *name, int vol); + std::optional findsound(const char *name, int vol); int addslot(const char *name, int vol); int addsound(const char *name, int vol, int maxuses = 0); void addalt(const char *name, int vol);