@@ -101,11 +101,6 @@ void SafeDelete(ILuaValue* value)
101
101
102
102
void FillValue (GarrysMod::Lua::ILuaBase* LUA, ILuaValue* val, int iStackPos, int type)
103
103
{
104
- LUA_Vector* vec;
105
- LUA_Angle* ang;
106
- LUA_File* file;
107
- LUA_File* copy;
108
- std::unordered_map<ILuaValue*, ILuaValue*> tbl;
109
104
switch (type)
110
105
{
111
106
case GarrysMod::Lua::Type::Number:
@@ -125,55 +120,63 @@ void FillValue(GarrysMod::Lua::ILuaBase* LUA, ILuaValue* val, int iStackPos, int
125
120
// val->number = ((CBaseEntity*)ILUA->GetObject(3)->GetEntity())->edict()->m_EdictIndex;
126
121
return ;
127
122
case GarrysMod::Lua::Type::Vector:
128
- val->type = type;
129
- vec = Vector_Get (LUA, iStackPos);
130
- val->x = vec->x ;
131
- val->y = vec->y ;
132
- val->z = vec->z ;
123
+ {
124
+ val->type = type;
125
+ LUA_Vector* vec = Vector_Get (LUA, iStackPos);
126
+ val->x = vec->x ;
127
+ val->y = vec->y ;
128
+ val->z = vec->z ;
129
+ }
133
130
return ;
134
131
case GarrysMod::Lua::Type::Angle:
135
- val->type = type;
136
- ang = Angle_Get (LUA, iStackPos);
137
- val->x = ang->x ;
138
- val->y = ang->y ;
139
- val->z = ang->z ;
132
+ {
133
+ val->type = type;
134
+ LUA_Angle* ang = Angle_Get (LUA, iStackPos);
135
+ val->x = ang->x ;
136
+ val->y = ang->y ;
137
+ val->z = ang->z ;
138
+ }
140
139
return ;
141
140
case GarrysMod::Lua::Type::Table:
142
- val->type = type;;
141
+ {
142
+ val->type = type;
143
+ std::unordered_map<ILuaValue*, ILuaValue*> tbl;
144
+ LUA->Push (iStackPos);
145
+ LUA->PushNil ();
146
+ while (LUA->Next (-2 )) {
147
+ LUA->Push (-2 );
143
148
144
- LUA->Push (iStackPos);
145
- LUA->PushNil ();
146
- while (LUA->Next (-2 )) {
147
- LUA->Push (-2 );
149
+ ILuaValue* key = new ILuaValue;
150
+ FillValue (LUA, key, -1 , LUA->GetType (-1 ));
148
151
149
- ILuaValue* key = new ILuaValue;
150
- FillValue (LUA, key , -1 , LUA->GetType (-1 ));
152
+ ILuaValue* new_val = new ILuaValue;
153
+ FillValue (LUA, new_val , -2 , LUA->GetType (-2 ));
151
154
152
- ILuaValue* new_val = new ILuaValue;
153
- FillValue (LUA, new_val, -2 , LUA->GetType (-2 ));
155
+ tbl[key] = new_val;
154
156
155
- tbl[key] = new_val;
157
+ LUA->Pop (2 );
158
+ }
159
+ LUA->Pop (1 );
156
160
157
- LUA-> Pop ( 2 ) ;
161
+ val-> tbl = tbl ;
158
162
}
159
- LUA->Pop (1 );
160
-
161
- val->tbl = tbl;
162
163
return ;
163
164
case GarrysMod::Lua::Type::File:
164
165
if (ThreadInMainThread ()) // We cannot push a File from GMod to our module.
165
166
{
166
167
return ;
167
168
}
168
169
169
- file = File_Get (LUA, iStackPos);
170
- copy = new LUA_File;
171
- copy->fileMode = file->fileMode ;
172
- copy->filename = file->filename ;
173
- copy->path = file->path ;
174
- // copy->handle = file->handle // Should we really share the handle?
175
- val->type = type;
176
- val->data = copy;
170
+ {
171
+ LUA_File* file = File_Get (LUA, iStackPos);
172
+ LUA_File* copy = new LUA_File;
173
+ copy->fileMode = file->fileMode ;
174
+ copy->filename = file->filename ;
175
+ copy->path = file->path ;
176
+ // copy->handle = file->handle // Should we really share the handle?
177
+ val->type = type;
178
+ val->data = copy;
179
+ }
177
180
return ;
178
181
default :
179
182
return ;
0 commit comments