aboutsummaryrefslogtreecommitdiff
path: root/src/universe.c
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-03-19 15:13:45 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2024-03-19 15:57:52 +0100
commit930bfb287de0a38746493463016d0e4cea153ac0 (patch)
tree2424f961d525e6b33cf4dda7c42cc2301e740a5f /src/universe.c
parent37e9658f74f9421aaae5fe71f12eb2221f2d574a (diff)
downloadlanes-930bfb287de0a38746493463016d0e4cea153ac0.tar.gz
lanes-930bfb287de0a38746493463016d0e4cea153ac0.tar.bz2
lanes-930bfb287de0a38746493463016d0e4cea153ac0.zip
C++ migration: changed file extensions from .c to .cpp
Diffstat (limited to 'src/universe.c')
-rw-r--r--src/universe.c75
1 files changed, 0 insertions, 75 deletions
diff --git a/src/universe.c b/src/universe.c
deleted file mode 100644
index 0a014f7..0000000
--- a/src/universe.c
+++ /dev/null
@@ -1,75 +0,0 @@
1/*
2 * UNIVERSE.C Copyright (c) 2017, Benoit Germain
3 */
4
5/*
6===============================================================================
7
8Copyright (C) 2017 Benoit Germain <bnt.germain@gmail.com>
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files (the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26THE SOFTWARE.
27
28===============================================================================
29*/
30
31#include <string.h>
32#include <assert.h>
33
34#include "universe.h"
35#include "compat.h"
36#include "macros_and_utils.h"
37#include "uniquekey.h"
38
39// crc64/we of string "UNIVERSE_REGKEY" generated at http://www.nitrxgen.net/hashgen/
40static DECLARE_CONST_UNIQUE_KEY( UNIVERSE_REGKEY, 0x9f877b2cf078f17f);
41
42// ################################################################################################
43
44Universe* universe_create( lua_State* L)
45{
46 Universe* U = (Universe*) lua_newuserdatauv( L, sizeof(Universe), 0); // universe
47 memset( U, 0, sizeof( Universe));
48 STACK_CHECK( L, 1);
49 REGISTRY_SET( L, UNIVERSE_REGKEY, lua_pushvalue(L, -2)); // universe
50 STACK_END( L, 1);
51 return U;
52}
53
54// ################################################################################################
55
56void universe_store( lua_State* L, Universe* U)
57{
58 STACK_CHECK( L, 0);
59 REGISTRY_SET( L, UNIVERSE_REGKEY, (NULL != U) ? lua_pushlightuserdata( L, U) : lua_pushnil( L));
60 STACK_END( L, 0);
61}
62
63// ################################################################################################
64
65Universe* universe_get( lua_State* L)
66{
67 Universe* universe;
68 STACK_GROW( L, 2);
69 STACK_CHECK( L, 0);
70 REGISTRY_GET( L, UNIVERSE_REGKEY);
71 universe = (Universe*) lua_touserdata( L, -1); // NULL if nil
72 lua_pop( L, 1);
73 STACK_END( L, 0);
74 return universe;
75}