Client Upload Part 2

RD Core / Commit #5

Commit Client Upload Part 2

Alex Alex committed 19/10/2026 00:06 main Patch
1,244 files +271,215 -0
A RD_Client/src/client/luavaluecasts_client.cpp +361-0 View file
@@ -0,0 +1,361 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+#include "luavaluecasts_client.h"
24+#include <framework/luaengine/luainterface.h>
25+
26+int push_luavalue(const Outfit& outfit)
27+{
28+ g_lua.createTable(0, 8);
29+ g_lua.pushInteger(outfit.getId());
30+ g_lua.setField("type");
31+ g_lua.pushInteger(outfit.getAuxId());
32+ g_lua.setField("auxType");
33+ if(g_game.getFeature(Otc::GamePlayerAddons)) {
34+ g_lua.pushInteger(outfit.getAddons());
35+ g_lua.setField("addons");
36+ }
37+ g_lua.pushInteger(outfit.getHead());
38+ g_lua.setField("head");
39+ g_lua.pushInteger(outfit.getBody());
40+ g_lua.setField("body");
41+ g_lua.pushInteger(outfit.getLegs());
42+ g_lua.setField("legs");
43+ g_lua.pushInteger(outfit.getFeet());
44+ g_lua.setField("feet");
45+ if (g_game.getFeature(Otc::GamePlayerMounts)) {
46+ g_lua.pushInteger(outfit.getMount());
47+ g_lua.setField("mount");
48+ }
49+ if (g_game.getFeature(Otc::GameWingsAndAura)) {
50+ g_lua.pushInteger(outfit.getWings());
51+ g_lua.setField("wings");
52+ g_lua.pushInteger(outfit.getAura());
53+ g_lua.setField("aura");
54+ }
55+ if (g_game.getFeature(Otc::GameOutfitShaders)) {
56+ g_lua.pushString(outfit.getShader());
57+ g_lua.setField("shader");
58+ }
59+ if (g_game.getFeature(Otc::GameHealthInfoBackground)) {
60+ g_lua.pushInteger(outfit.getHealthBar());
61+ g_lua.setField("healthBar");
62+ g_lua.pushInteger(outfit.getManaBar());
63+ g_lua.setField("manaBar");
64+ }
65+ if (g_game.getFeature(Otc::GameOutfitAttackData)) {
66+ g_lua.pushInteger(outfit.getRuneEffect());
67+ g_lua.setField("runeEffect");
68+ g_lua.pushInteger(outfit.getAttackLookType());
69+ g_lua.setField("attackType");
70+ g_lua.pushInteger(outfit.getAttackRange());
71+ g_lua.setField("attackRange");
72+ }
73+ return 1;
74+}
75+
76+bool luavalue_cast(int index, Outfit& outfit)
77+{
78+ if(g_lua.isTable(index)) {
79+ g_lua.getField("type", index);
80+ outfit.setId(g_lua.popInteger());
81+ g_lua.getField("auxType", index);
82+ outfit.setAuxId(g_lua.popInteger());
83+ if(g_game.getFeature(Otc::GamePlayerAddons)) {
84+ g_lua.getField("addons", index);
85+ outfit.setAddons(g_lua.popInteger());
86+ }
87+ g_lua.getField("head", index);
88+ outfit.setHead(g_lua.popInteger());
89+ g_lua.getField("body", index);
90+ outfit.setBody(g_lua.popInteger());
91+ g_lua.getField("legs", index);
92+ outfit.setLegs(g_lua.popInteger());
93+ g_lua.getField("feet", index);
94+ outfit.setFeet(g_lua.popInteger());
95+ if (g_game.getFeature(Otc::GamePlayerMounts)) {
96+ g_lua.getField("mount", index);
97+ outfit.setMount(g_lua.popInteger());
98+ }
99+ if (g_game.getFeature(Otc::GameWingsAndAura)) {
100+ g_lua.getField("wings", index);
101+ outfit.setWings(g_lua.popInteger());
102+ g_lua.getField("aura", index);
103+ outfit.setAura(g_lua.popInteger());
104+ }
105+ //if (g_game.getFeature(Otc::GameOutfitShaders)) {
106+ g_lua.getField("shader", index);
107+ outfit.setShader(g_lua.popString());
108+ //}
109+ if (g_game.getFeature(Otc::GameHealthInfoBackground)) {
110+ g_lua.getField("healthBar", index);
111+ outfit.setHealthBar(g_lua.popInteger());
112+ g_lua.getField("manaBar", index);
113+ outfit.setManaBar(g_lua.popInteger());
114+ }
115+ if (g_game.getFeature(Otc::GameOutfitAttackData)) {
116+ g_lua.getField("runeEffect", index);
117+ outfit.setRuneEffect(g_lua.popInteger());
118+ }
119+ return true;
120+ }
121+ return false;
122+}
123+
124+int push_luavalue(const Position& pos)
125+{
126+ if(pos.isValid()) {
127+ g_lua.createTable(0, 3);
128+ g_lua.pushInteger(pos.x);
129+ g_lua.setField("x");
130+ g_lua.pushInteger(pos.y);
131+ g_lua.setField("y");
132+ g_lua.pushInteger(pos.z);
133+ g_lua.setField("z");
134+ } else
135+ g_lua.pushNil();
136+ return 1;
137+}
138+
139+bool luavalue_cast(int index, Position& pos)
140+{
141+ if(g_lua.isTable(index)) {
142+ g_lua.getField("x", index);
143+ pos.x = g_lua.popInteger();
144+ g_lua.getField("y", index);
145+ pos.y = g_lua.popInteger();
146+ g_lua.getField("z", index);
147+ pos.z = g_lua.popInteger();
148+ return true;
149+ }
150+ return false;
151+}
152+
153+int push_luavalue(const MarketData& data)
154+{
155+ g_lua.createTable(0, 6);
156+ g_lua.pushInteger(data.category);
157+ g_lua.setField("category");
158+ g_lua.pushString(data.name);
159+ g_lua.setField("name");
160+ g_lua.pushInteger(data.requiredLevel);
161+ g_lua.setField("requiredLevel");
162+ g_lua.pushInteger(data.restrictVocation);
163+ g_lua.setField("restrictVocation");
164+ g_lua.pushInteger(data.showAs);
165+ g_lua.setField("showAs");
166+ g_lua.pushInteger(data.tradeAs);
167+ g_lua.setField("tradeAs");
168+ return 1;
169+}
170+
171+bool luavalue_cast(int index, MarketData& data)
172+{
173+ if (g_lua.isTable(index)) {
174+ g_lua.getField("category", index);
175+ data.category = g_lua.popInteger();
176+ g_lua.getField("name", index);
177+ data.name = g_lua.popString();
178+ g_lua.getField("requiredLevel", index);
179+ data.requiredLevel = g_lua.popInteger();
180+ g_lua.getField("restrictVocation", index);
181+ data.restrictVocation = g_lua.popInteger();
182+ g_lua.getField("showAs", index);
183+ data.showAs = g_lua.popInteger();
184+ g_lua.getField("tradeAs", index);
185+ data.tradeAs = g_lua.popInteger();
186+ return true;
187+ }
188+ return false;
189+}
190+
191+int push_luavalue(const StoreCategory& category)
192+{
193+ g_lua.createTable(0, 5);
194+ g_lua.pushString(category.name);
195+ g_lua.setField("name");
196+ g_lua.pushString(category.description);
197+ g_lua.setField("description");
198+ g_lua.pushInteger(category.state);
199+ g_lua.setField("state");
200+ g_lua.pushString(category.icon);
201+ g_lua.setField("icon");
202+ g_lua.pushString(category.parent);
203+ g_lua.setField("parent");
204+ return 1;
205+}
206+
207+bool luavalue_cast(int index, StoreCategory& data)
208+{
209+ if (g_lua.isTable(index)) {
210+ g_lua.getField("name", index);
211+ data.name = g_lua.popString();
212+ g_lua.getField("description", index);
213+ data.description = g_lua.popString();
214+ g_lua.getField("state", index);
215+ data.state = g_lua.popInteger();
216+ g_lua.getField("icon", index);
217+ data.icon = g_lua.popString();
218+ g_lua.getField("parent", index);
219+ data.parent = g_lua.popString();
220+ return true;
221+ }
222+ return false;
223+}
224+
225+int push_luavalue(const StoreOffer& offer)
226+{
227+ g_lua.createTable(0, 6);
228+ g_lua.pushInteger(offer.id);
229+ g_lua.setField("id");
230+ g_lua.pushString(offer.name);
231+ g_lua.setField("name");
232+ g_lua.pushString(offer.description);
233+ g_lua.setField("description");
234+ g_lua.pushInteger(offer.price);
235+ g_lua.setField("price");
236+ g_lua.pushInteger(offer.state);
237+ g_lua.setField("state");
238+ g_lua.pushString(offer.icon);
239+ g_lua.setField("icon");
240+ return 1;
241+}
242+
243+bool luavalue_cast(int index, StoreOffer& data)
244+{
245+ if (g_lua.isTable(index)) {
246+ g_lua.getField("id", index);
247+ data.id = g_lua.popInteger();
248+ g_lua.getField("name", index);
249+ data.name = g_lua.popString();
250+ g_lua.getField("description", index);
251+ data.description = g_lua.popString();
252+ g_lua.getField("state", index);
253+ data.state = g_lua.popInteger();
254+ g_lua.getField("price", index);
255+ data.price = g_lua.popInteger();
256+ g_lua.getField("icon", index);
257+ data.icon = g_lua.popString();
258+ return true;
259+ }
260+ return false;
261+}
262+
263+int push_luavalue(const Imbuement& i)
264+{
265+ g_lua.createTable(0, 11);
266+ g_lua.pushInteger(i.id);
267+ g_lua.setField("id");
268+ g_lua.pushString(i.name);
269+ g_lua.setField("name");
270+ g_lua.pushString(i.description);
271+ g_lua.setField("description");
272+ g_lua.pushString(i.group);
273+ g_lua.setField("group");
274+ g_lua.pushInteger(i.imageId);
275+ g_lua.setField("imageId");
276+ g_lua.pushInteger(i.duration);
277+ g_lua.setField("duration");
278+ g_lua.pushBoolean(i.premiumOnly);
279+ g_lua.setField("premiumOnly");
280+ g_lua.createTable(i.sources.size(), 0);
281+ for (size_t j = 0; j < i.sources.size(); ++j) {
282+ g_lua.createTable(0, 2);
283+ g_lua.pushObject(i.sources[j].first);
284+ g_lua.setField("item");
285+ g_lua.pushString(i.sources[j].second);
286+ g_lua.setField("description");
287+ g_lua.rawSeti(j + 1);
288+ }
289+ g_lua.setField("sources");
290+ g_lua.pushInteger(i.cost);
291+ g_lua.setField("cost");
292+ g_lua.pushInteger(i.successRate);
293+ g_lua.setField("successRate");
294+ g_lua.pushInteger(i.protectionCost);
295+ g_lua.setField("protectionCost");
296+ return 1;
297+}
298+
299+int push_luavalue(const Light& light)
300+{
301+ g_lua.createTable(0, 2);
302+ g_lua.pushInteger(light.color);
303+ g_lua.setField("color");
304+ g_lua.pushInteger(light.intensity);
305+ g_lua.setField("intensity");
306+ return 1;
307+}
308+
309+bool luavalue_cast(int index, Light& light)
310+{
311+ if(g_lua.isTable(index)) {
312+ g_lua.getField("color", index);
313+ light.color = g_lua.popInteger();
314+ g_lua.getField("intensity", index);
315+ light.intensity = g_lua.popInteger();
316+ return true;
317+ }
318+ return false;
319+}
320+
321+int push_luavalue(const UnjustifiedPoints& unjustifiedPoints)
322+{
323+ g_lua.createTable(0, 7);
324+ g_lua.pushInteger(unjustifiedPoints.killsDay);
325+ g_lua.setField("killsDay");
326+ g_lua.pushInteger(unjustifiedPoints.killsDayRemaining);
327+ g_lua.setField("killsDayRemaining");
328+ g_lua.pushInteger(unjustifiedPoints.killsWeek);
329+ g_lua.setField("killsWeek");
330+ g_lua.pushInteger(unjustifiedPoints.killsWeekRemaining);
331+ g_lua.setField("killsWeekRemaining");
332+ g_lua.pushInteger(unjustifiedPoints.killsMonth);
333+ g_lua.setField("killsMonth");
334+ g_lua.pushInteger(unjustifiedPoints.killsMonthRemaining);
335+ g_lua.setField("killsMonthRemaining");
336+ g_lua.pushInteger(unjustifiedPoints.skullTime);
337+ g_lua.setField("skullTime");
338+ return 1;
339+}
340+
341+bool luavalue_cast(int index, UnjustifiedPoints& unjustifiedPoints)
342+{
343+ if(g_lua.isTable(index)) {
344+ g_lua.getField("killsDay", index);
345+ unjustifiedPoints.killsDay = g_lua.popInteger();
346+ g_lua.getField("killsDayRemaining", index);
347+ unjustifiedPoints.killsDayRemaining = g_lua.popInteger();
348+ g_lua.getField("killsWeek", index);
349+ unjustifiedPoints.killsWeek = g_lua.popInteger();
350+ g_lua.getField("killsWeekRemaining", index);
351+ unjustifiedPoints.killsWeekRemaining = g_lua.popInteger();
352+ g_lua.getField("killsMonth", index);
353+ unjustifiedPoints.killsMonth = g_lua.popInteger();
354+ g_lua.getField("killsMonthRemaining", index);
355+ unjustifiedPoints.killsMonthRemaining = g_lua.popInteger();
356+ g_lua.getField("skullTime", index);
357+ unjustifiedPoints.skullTime = g_lua.popInteger();
358+ return true;
359+ }
360+ return false;
361+}
A RD_Client/src/client/luavaluecasts_client.h +62-0 View file
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+#ifndef CLIENT_LUAVALUECASTS_H
24+#define CLIENT_LUAVALUECASTS_H
25+
26+#include "global.h"
27+#include <framework/luaengine/declarations.h>
28+#include "game.h"
29+#include "outfit.h"
30+
31+// outfit
32+int push_luavalue(const Outfit& outfit);
33+bool luavalue_cast(int index, Outfit& outfit);
34+
35+// position
36+int push_luavalue(const Position& pos);
37+bool luavalue_cast(int index, Position& pos);
38+
39+// market
40+int push_luavalue(const MarketData& data);
41+bool luavalue_cast(int index, MarketData& data);
42+
43+// store category
44+int push_luavalue(const StoreCategory& category);
45+bool luavalue_cast(int index, StoreCategory& data);
46+
47+// store offer
48+int push_luavalue(const StoreOffer& offer);
49+bool luavalue_cast(int index, StoreOffer& offer);
50+
51+// imbuement
52+int push_luavalue(const Imbuement& offer);
53+
54+// light
55+int push_luavalue(const Light& light);
56+bool luavalue_cast(int index, Light& light);
57+
58+// unjustified points
59+int push_luavalue(const UnjustifiedPoints& unjustifiedPoints);
60+bool luavalue_cast(int index, UnjustifiedPoints& unjustifiedPoints);
61+
62+#endif
Top