Skip to content

Commit 9a864ed

Browse files
committed
Merge branch 'release/2.x' into dev/v3
2 parents ace0e5f + c9b63a7 commit 9a864ed

File tree

16 files changed

+200
-776
lines changed

16 files changed

+200
-776
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: publish
22

33
on:
44
push:
5+
branches:
6+
- dev/*
7+
- release/*
58
paths:
69
- CHANGELOG.md
710
workflow_dispatch:

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# axmol-2.8.1 ?? 2025
1+
# axmol-2.8.1 Sep.5 2025
22

3-
## Bug Fixes
3+
## Bug fixes
44

5-
- **Fix a regression introduced by 2.8.0 that improper Content-Length setting in HTTP requests, see #2686** by @halx99
5+
- **Fix a regression introduced by 2.8.0 that improper Content-Length setting in HTTP requests, see [#2686](https://github.com/axmolengine/axmol/issues/2686)** by @halx99
66
- Fix compile error when using AX_CORE_PROFILE option by @martinking71 in [#2677](https://github.com/axmolengine/axmol/pull/2677)
77
- Fix lua-tests PhysicsTest not work by @halx99
88
- Fix missing processor endif in platform/mac/GL-mac.h by @halx99
@@ -23,7 +23,7 @@
2323
- Remove entries for non-existent Lua test cases by @halx99
2424
- Fix incorrect fmt::format format string by @halx99
2525
- Remove "CC" from the menu entries (cpp-/lua-tests) by @aismann in [#2688](https://github.com/axmolengine/axmol/pull/2688)
26-
- Remove unnecessary Lua files: LayerEx.lua, DrawPrimitives.lua.lua by @halx99
26+
- Remove unnecessary Lua files: LayerEx.lua, DrawPrimitives.lua by @halx99
2727
- Use lua length operator `#` instead `table.getn` in CocoStudio.lua by @halx99
2828
- Update url of CurlTeset by @halx99
2929
- Ensure lua-tests RenderTextureTest case work as expected by @halx99

axmol/base/Director.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ Director::~Director()
177177
_rendererRecreatedListener = nullptr;
178178
#endif
179179

180+
#if AX_ENABLE_SCRIPT_BINDING
181+
// !!!ScriptEngine instance depends on _scheduler, so must dtor before _scheduler
182+
ScriptEngineManager::destroyInstance();
183+
#endif
184+
180185
AX_SAFE_RELEASE(_scheduler);
181186
AX_SAFE_RELEASE(_actionManager);
182187

@@ -198,10 +203,6 @@ Director::~Director()
198203
ObjectFactory::destroyInstance();
199204
QuadCommand::destroyIsolatedIndices();
200205

201-
#if AX_ENABLE_SCRIPT_BINDING
202-
ScriptEngineManager::destroyInstance();
203-
#endif
204-
205206
/** clean auto release pool. */
206207
PoolManager::destroyInstance();
207208

@@ -1109,7 +1110,7 @@ void Director::restartDirector()
11091110
ScriptEngineManager::sendEventToLua(scriptEvent);
11101111
#endif
11111112

1112-
setGLDefaultValues();
1113+
setRenderDefaults();
11131114

11141115
#if AX_ENABLE_CONTEXT_LOSS_RECOVERY
11151116
// listen the event that renderer was recreated on Android/WP8

extensions/scripting/lua-bindings/manual/network/lua_websocket.cpp

Lines changed: 25 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -37,44 +37,6 @@
3737

3838
using namespace ax;
3939

40-
static int SendBinaryMessageToLua(int nHandler, const unsigned char* pTable, int nLength)
41-
{
42-
if (NULL == pTable || nHandler <= 0)
43-
{
44-
return 0;
45-
}
46-
47-
if (NULL == ScriptEngineManager::getInstance()->getScriptEngine())
48-
{
49-
return 0;
50-
}
51-
52-
LuaStack* pStack = LuaEngine::getInstance()->getLuaStack();
53-
if (NULL == pStack)
54-
{
55-
return 0;
56-
}
57-
58-
lua_State* tolua_s = pStack->getLuaState();
59-
if (NULL == tolua_s)
60-
{
61-
return 0;
62-
}
63-
64-
int nRet = 0;
65-
LuaValueArray array;
66-
for (int i = 0; i < nLength; i++)
67-
{
68-
LuaValue value = LuaValue::intValue(pTable[i]);
69-
array.push_back(value);
70-
}
71-
72-
pStack->pushLuaValueArray(array);
73-
nRet = pStack->executeFunctionByHandler(nHandler, 1);
74-
pStack->clean();
75-
return nRet;
76-
}
77-
7840
LuaWebSocket::~LuaWebSocket()
7941
{
8042
ScriptHandlerMgr::getInstance()->removeObjectAllHandlers((void*)this);
@@ -83,7 +45,7 @@ LuaWebSocket::~LuaWebSocket()
8345
void LuaWebSocket::onOpen(WebSocket* ws)
8446
{
8547
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
86-
if (NULL != luaWs)
48+
if (luaWs)
8749
{
8850
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,
8951
ScriptHandlerMgr::HandlerType::WEBSOCKET_OPEN);
@@ -99,30 +61,18 @@ void LuaWebSocket::onOpen(WebSocket* ws)
9961
void LuaWebSocket::onMessage(WebSocket* ws, const WebSocket::Data& data)
10062
{
10163
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
102-
if (NULL != luaWs)
64+
if (luaWs)
10365
{
104-
if (data.isBinary)
66+
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(
67+
(void*)this, ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE);
68+
if (0 != handler)
10569
{
106-
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(
107-
(void*)this, ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE);
108-
if (0 != handler)
109-
{
110-
SendBinaryMessageToLua(handler, (const unsigned char*)data.bytes, (int)data.len);
111-
}
112-
}
113-
else
114-
{
115-
116-
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(
117-
(void*)this, ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE);
118-
if (0 != handler)
70+
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
71+
if (nullptr != stack)
11972
{
120-
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
121-
if (nullptr != stack)
122-
{
123-
stack->pushString(data.bytes, (int)data.len);
124-
stack->executeFunctionByHandler(handler, 1);
125-
}
73+
stack->pushString(data.bytes, (int)data.len);
74+
stack->pushBoolean(data.isBinary);
75+
stack->executeFunctionByHandler(handler, 2);
12676
}
12777
}
12878
}
@@ -131,7 +81,7 @@ void LuaWebSocket::onMessage(WebSocket* ws, const WebSocket::Data& data)
13181
void LuaWebSocket::onClose(WebSocket* ws, uint16_t code, std::string_view reason)
13282
{
13383
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
134-
if (NULL != luaWs)
84+
if (luaWs)
13585
{
13686
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler(
13787
(void*)this, ScriptHandlerMgr::HandlerType::WEBSOCKET_CLOSE);
@@ -147,7 +97,7 @@ void LuaWebSocket::onClose(WebSocket* ws, uint16_t code, std::string_view reason
14797
void LuaWebSocket::onError(WebSocket* ws, const WebSocket::ErrorCode& error)
14898
{
14999
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
150-
if (NULL != luaWs)
100+
if (luaWs)
151101
{
152102
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler(
153103
(void*)this, ScriptHandlerMgr::HandlerType::WEBSOCKET_ERROR);
@@ -186,7 +136,7 @@ static int axlua_WebSocket_create00(lua_State* tolua_S)
186136
if (argumentCount >= 2)
187137
{
188138
std::string_view url;
189-
const char* protocols{nullptr};
139+
std::string_view protocols = ""sv;
190140
std::string_view caCertPath;
191141

192142
# ifndef TOLUA_RELEASE
@@ -210,7 +160,7 @@ static int axlua_WebSocket_create00(lua_State* tolua_S)
210160
else if (argumentCount == 4)
211161
{
212162
luaval_to_std_string_view(tolua_S, 3, &caCertPath);
213-
protocols = lua_tostring(tolua_S, 4);
163+
protocols = axlua_tosv(tolua_S, 4);
214164
}
215165

216166
luaval_to_std_string_view(tolua_S, 2, &url);
@@ -242,7 +192,7 @@ static int axlua_WebSocket_getReadyState00(lua_State* tolua_S)
242192
{
243193
LuaWebSocket* self = (LuaWebSocket*)tolua_tousertype(tolua_S, 1, 0);
244194
int tolua_ret = -1;
245-
if (NULL != self)
195+
if (self)
246196
{
247197
tolua_ret = (int)self->getReadyState();
248198
}
@@ -269,7 +219,7 @@ static int axlua_WebSocket_close00(lua_State* tolua_S)
269219
# endif
270220
{
271221
LuaWebSocket* self = (LuaWebSocket*)tolua_tousertype(tolua_S, 1, 0);
272-
if (NULL != self)
222+
if (self)
273223
{
274224
self->closeAsync();
275225
}
@@ -298,7 +248,7 @@ static int axlua_WebSocket_sendString00(lua_State* tolua_S)
298248
LuaWebSocket* self = (LuaWebSocket*)tolua_tousertype(tolua_S, 1, 0);
299249
size_t size = 0;
300250
const char* data = (const char*)lua_tolstring(tolua_S, 2, &size);
301-
if (NULL == data)
251+
if (!data)
302252
return 0;
303253

304254
if (strlen(data) != size)
@@ -368,7 +318,7 @@ TOLUA_API int tolua_web_socket_open(lua_State* tolua_S)
368318
#ifdef __cplusplus
369319
tolua_cclass(tolua_S, "WebSocket", "ax.WebSocket", "", tolua_collect_WebSocket);
370320
#else
371-
tolua_cclass(tolua_S, "WebSocket", "ax.WebSocket", "", NULL);
321+
tolua_cclass(tolua_S, "WebSocket", "ax.WebSocket", "", nullptr);
372322
#endif
373323
tolua_beginmodule(tolua_S, "WebSocket");
374324
tolua_function(tolua_S, "create", axlua_WebSocket_create00);
@@ -394,12 +344,11 @@ int axlua_WebSocket_registerScriptHandler00(lua_State* tolua_S)
394344
#endif
395345
{
396346
LuaWebSocket* self = (LuaWebSocket*)tolua_tousertype(tolua_S, 1, 0);
397-
if (NULL != self)
347+
if (self)
398348
{
399-
int handler = (toluafix_ref_function(tolua_S, 2, 0));
400-
ScriptHandlerMgr::HandlerType handlerType =
401-
(ScriptHandlerMgr::HandlerType)((int)tolua_tonumber(tolua_S, 3, 0) +
402-
(int)ScriptHandlerMgr::HandlerType::WEBSOCKET_OPEN);
349+
int handler = (toluafix_ref_function(tolua_S, 2, 0));
350+
ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType)(
351+
(int)tolua_tonumber(tolua_S, 3, 0) + (int)ScriptHandlerMgr::HandlerType::WEBSOCKET_OPEN);
403352
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType);
404353
}
405354
}
@@ -422,11 +371,10 @@ int axlua_WebSocket_unregisterScriptHandler00(lua_State* tolua_S)
422371
#endif
423372
{
424373
LuaWebSocket* self = (LuaWebSocket*)tolua_tousertype(tolua_S, 1, 0);
425-
if (NULL != self)
374+
if (self)
426375
{
427-
ScriptHandlerMgr::HandlerType handlerType =
428-
(ScriptHandlerMgr::HandlerType)((int)tolua_tonumber(tolua_S, 2, 0) +
429-
(int)ScriptHandlerMgr::HandlerType::WEBSOCKET_OPEN);
376+
ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType)(
377+
(int)tolua_tonumber(tolua_S, 2, 0) + (int)ScriptHandlerMgr::HandlerType::WEBSOCKET_OPEN);
430378

431379
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType);
432380
}

tests/cpp-tests/Source/NetworkTest/WebSocketTest/WebSocketTest.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@
2929

3030
#include "axmol/tlx/format.hpp"
3131

32-
/* "ws://echo.websocket.org no longer avaiable: https://www.lob.com/blog/websocket-org-is-down-here-is-an-alternative
33-
list of public test servers:
34-
- wss://echo.websocket.events/.ws
35-
- wss://ws.postman-echo.com/raw
36-
- wss://ws.postman-echo.com/socketio handshake path: random, handling
37-
- wss://socketsbay.com/wss/v2/1/demo/
32+
/* https://websocket.org/
33+
list of public test servers: (Note, on china mainland, may need VPN):
34+
- wss://ws.ifelse.io (available, test on Sep.5 2025)
35+
- wss://echo.websocket.org (available, test on Sep.5 2025)
36+
- wss://echo.websocket.events/.ws (unavailable, test on Sep.5 2025)
37+
- wss://ws.postman-echo.com/raw (not test)
38+
- wss://ws.postman-echo.com/socketio handshake path: random, handling (not test)
39+
- wss://socketsbay.com/wss/v2/1/demo/ (not test)
3840
- https://blog.postman.com/introducing-postman-websocket-echo-service/
41+
- other https://www.lob.com/blog/websocket-org-is-down-here-is-an-alternative
3942
*/
40-
#define ECHO_SERVER_URL "wss://echo.websocket.events/.ws" //"wss://ws.postman-echo.com/raw"
43+
#define ECHO_SERVER_URL "wss://ws.ifelse.io"
4144
#define SOCKETIO_SERVICE "wss://ws.postman-echo.com/socketio"
4245

4346
using namespace ax;

tests/cpp-tests/Source/TileMapTest/TileMapTest2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ FastTileMapTests::FastTileMapTests()
7373
TileDemoNew::TileDemoNew()
7474
{
7575
// fix bug #486, #419.
76-
// "test" is the default value in Director::setGLDefaultValues()
76+
// "test" is the default value in Director::setRenderDefaults()
7777
// but TransitionTest may setDepthTest(false), we should revert it here
7878
Director::getInstance()->getRenderer()->setDepthTest(true);
7979
Director::getInstance()->getRenderer()->setDepthWrite(true);

tests/lua-tests/Content/src/DownloaderTest/DownloaderTest.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local json = cjson
1+
local json = require 'cjson'
22

33

44
local imgURI = "https://forum.cocos.com/images/logo.png"

tests/lua-tests/Content/src/DrawNodeTest/DrawNodeTest.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

2-
3-
local function drawNodeMainLayer()
2+
local function DrawNodeMainLayer()
43
local kItemTagBasic = 1000
54
local testCount = 1
65
local maxCases = testCount
@@ -197,7 +196,7 @@ end
197196

198197
function DrawNodeTest()
199198
local scene = ax.Scene:create()
200-
scene:addChild(drawNodeMainLayer())
199+
scene:addChild(DrawNodeMainLayer())
201200
scene:addChild(CreateBackMenuItem())
202201
return scene
203202
end

tests/lua-tests/Content/src/ExtensionTest/ExtensionTest.lua

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -193,40 +193,6 @@ local function ExtensionsMainLayer()
193193

194194
layer:addChild(menu)
195195

196-
-- handling touch events
197-
local beginPos = {x = 0, y = 0}
198-
local function onTouchesBegan(touches, event)
199-
beginPos = touches[1]:getLocation()
200-
end
201-
202-
local function onTouchesMoved(touches, event)
203-
local location = touches[1]:getLocation()
204-
205-
local nMoveY = location.y - beginPos.y
206-
local curPosx, curPosy = menu:getPosition()
207-
local nextPosy = curPosy + nMoveY
208-
local winSize = ax.Director:getInstance():getWinSize()
209-
if nextPosy < 0 then
210-
menu:setPosition(0, 0)
211-
return
212-
end
213-
214-
if nextPosy > ((ExtensionTestEnum.TEST_MAX_COUNT + 1) * LINE_SPACE - winSize.height) then
215-
menu:setPosition(0, ((ExtensionTestEnum.TEST_MAX_COUNT + 1) * LINE_SPACE - winSize.height))
216-
return
217-
end
218-
219-
menu:setPosition(curPosx, nextPosy)
220-
beginPos = {x = location.x, y = location.y}
221-
end
222-
223-
local listener = ax.EventListenerTouchAllAtOnce:create()
224-
listener:registerScriptHandler(onTouchesBegan,ax.Handler.EVENT_TOUCHES_BEGAN )
225-
listener:registerScriptHandler(onTouchesMoved,ax.Handler.EVENT_TOUCHES_MOVED )
226-
227-
local eventDispatcher = layer:getEventDispatcher()
228-
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layer)
229-
230196
return layer
231197
end
232198

0 commit comments

Comments
 (0)