ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.113 by root, Fri Apr 22 02:03:11 2011 UTC vs.
Revision 1.115 by root, Tue Apr 26 14:41:36 2011 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 5 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 6 * Deliantra is free software: you can redistribute it and/or modify it under
7 * the terms of the Affero GNU General Public License as published by the 7 * the terms of the Affero GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your 8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version. 9 * option) any later version.
252#else 252#else
253 return dx_ + dy_ - min (dx_, dy_) * 5 / 8; 253 return dx_ + dy_ - min (dx_, dy_) * 5 / 8;
254#endif 254#endif
255} 255}
256 256
257// can be substantially faster than floor, if your value range allows for it
258template<typename T>
259inline T
260fastfloor (T x)
261{
262 return std::floor (x);
263}
264
265inline float
266fastfloor (float x)
267{
268 return sint32(x) - (x < 0);
269}
270
271inline double
272fastfloor (double x)
273{
274 return sint64(x) - (x < 0);
275}
276
257/* 277/*
258 * absdir(int): Returns a number between 1 and 8, which represent 278 * absdir(int): Returns a number between 1 and 8, which represent
259 * the "absolute" direction of a number (it actually takes care of 279 * the "absolute" direction of a number (it actually takes care of
260 * "overflow" in previous calculations of a direction). 280 * "overflow" in previous calculations of a direction).
261 */ 281 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines