@@ -144,62 +144,48 @@ BOOL CModulePlugin_LuaCore::ModulePlugin_LuaCore_Exec(XNETHANDLE xhModule, TCHAR
144144 st_csStl.unlock_shared ();
145145 return FALSE ;
146146 }
147-
148- if (0 == lua_getglobal (stl_MapIterator->second .pSt_LuaState , " PluginCore_Call1" ))
147+ if (0 == lua_getglobal (stl_MapIterator->second .pSt_LuaState , " PluginCore_Call" ))
149148 {
149+ ModulePlugin_IsErrorOccur = TRUE ;
150+ ModulePlugin_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PLUGIN_FPCALL;
151+ st_csStl.unlock_shared ();
150152 return FALSE ;
151153 }
154+ TCHAR tszURLParam[MAX_PATH];
155+ memset (tszURLParam, ' \0 ' , MAX_PATH);
152156
153- lua_pushstring (stl_MapIterator->second .pSt_LuaState , " 1" );
154- lua_pushstring (stl_MapIterator->second .pSt_LuaState , " 2" );
155- lua_pushinteger (stl_MapIterator->second .pSt_LuaState , 3 );
156- int nRet = lua_pcall (stl_MapIterator->second .pSt_LuaState , 3 , 0 , 0 );
157-
158- lua_getglobal (stl_MapIterator->second .pSt_LuaState , " pInt_HTTPCode" );
159- *pInt_HTTPCode = lua_tonumber (stl_MapIterator->second .pSt_LuaState , -1 );
160- lua_pop (stl_MapIterator->second .pSt_LuaState , -1 );
161-
162- lua_getglobal (stl_MapIterator->second .pSt_LuaState , " pInt_MsgLen" );
163- *pInt_MsgLen = lua_tonumber (stl_MapIterator->second .pSt_LuaState , -1 );
157+ for (int i = 1 ; i < nListCount; i++)
158+ {
159+ if (i > 1 )
160+ {
161+ _tcscat (tszURLParam, " &" );
162+ }
163+ _tcscat (tszURLParam, (*pppHDRList)[i]);
164+ }
165+ lua_pushstring (stl_MapIterator->second .pSt_LuaState , tszURLParam);
166+ lua_pushinteger (stl_MapIterator->second .pSt_LuaState , nListCount - 1 );
167+ lua_pushstring (stl_MapIterator->second .pSt_LuaState , lpszMsgBufer);
168+ lua_pushinteger (stl_MapIterator->second .pSt_LuaState , nMsgLen);
169+ if (LUA_OK != lua_pcall (stl_MapIterator->second .pSt_LuaState , 4 , 1 , 0 ))
170+ {
171+ ModulePlugin_IsErrorOccur = TRUE ;
172+ ModulePlugin_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PLUGIN_EXECTION;
173+ st_csStl.unlock_shared ();
174+ return FALSE ;
175+ }
176+ lua_getglobal (stl_MapIterator->second .pSt_LuaState , " PInt_HTTPCode" );
177+ *pInt_HTTPCode = (int )lua_tonumber (stl_MapIterator->second .pSt_LuaState , -1 );
164178 lua_pop (stl_MapIterator->second .pSt_LuaState , -1 );
165179
166- lua_getglobal (stl_MapIterator->second .pSt_LuaState , " ptszMsgBuffer " );
167- LPCTSTR lpszStr = lua_tostring (stl_MapIterator->second .pSt_LuaState , -1 );
180+ lua_getglobal (stl_MapIterator->second .pSt_LuaState , " PtszMsgBuffer " );
181+ _tcscpy (ptszMsgBuffer, lua_tostring (stl_MapIterator->second .pSt_LuaState , -1 ) );
168182 lua_pop (stl_MapIterator->second .pSt_LuaState , -1 );
169- /*
170- lua_newtable(stl_MapIterator->second.pSt_LuaState);
171- for (int i = 0; i < nListCount; i++)
172- {
173- TCHAR tszStrKey[64];
174- TCHAR tszStrValue[64];
175-
176- memset(tszStrKey, '\0', sizeof(tszStrKey));
177- memset(tszStrValue, '\0', sizeof(tszStrValue));
178- BaseLib_OperatorString_GetKeyValue((*pppHDRList)[i], "=", tszStrKey, tszStrValue);
179-
180- lua_pushstring(stl_MapIterator->second.pSt_LuaState, tszStrKey);
181- lua_pushstring(stl_MapIterator->second.pSt_LuaState, tszStrValue);
182- lua_settable(stl_MapIterator->second.pSt_LuaState, -3);
183- }
184- lua_pushnumber(stl_MapIterator->second.pSt_LuaState, nListCount);
185-
186- int nRet = 0;
187- if (NULL == lpszMsgBufer)
188- {
189- lua_pushstring(stl_MapIterator->second.pSt_LuaState, "");
190- lua_pushinteger(stl_MapIterator->second.pSt_LuaState, 0);
191183
192- nRet = lua_pcall(stl_MapIterator->second.pSt_LuaState, 7, 1, 0);
193- }
194- else
195- {
196- lua_pushstring(stl_MapIterator->second.pSt_LuaState, lpszMsgBufer);
197- lua_pushinteger(stl_MapIterator->second.pSt_LuaState, nMsgLen);
184+ lua_getglobal (stl_MapIterator->second .pSt_LuaState , " PInt_MsgLen" );
185+ *pInt_MsgLen = (int )lua_tonumber (stl_MapIterator->second .pSt_LuaState , -1 );
186+ lua_pop (stl_MapIterator->second .pSt_LuaState , -1 );
198187
199- nRet = lua_pcall(stl_MapIterator->second.pSt_LuaState, 7, 1, 0);
200- }
201- */
202- st_csStl.unlock_shared ();
188+ st_csStl.unlock_shared ();
203189
204190 return TRUE ;
205191}
@@ -280,42 +266,45 @@ BOOL CModulePlugin_LuaCore::ModulePlugin_LuaCore_Add(XNETHANDLE xhNet, LPCTSTR l
280266
281267 if (NULL == st_LuaCore.pSt_LuaState )
282268 {
269+ ModulePlugin_IsErrorOccur = TRUE ;
270+ ModulePlugin_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PLUGIN_MALLOC;
283271 return FALSE ;
284272 }
285273 luaL_openlibs (st_LuaCore.pSt_LuaState );
286274
287- if (0 != luaL_loadfile (st_LuaCore.pSt_LuaState , lpszPluginFile))
275+ if (LUA_OK != luaL_loadfile (st_LuaCore.pSt_LuaState , lpszPluginFile))
288276 {
289- return FALSE ;
290- }
291- if (0 != lua_pcall (st_LuaCore.pSt_LuaState , 0 , 0 , 0 ))
292- {
293- return FALSE ;
277+ ModulePlugin_IsErrorOccur = TRUE ;
278+ ModulePlugin_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PLUGIN_OPENDL;
279+ return FALSE ;
294280 }
281+ if (LUA_OK != lua_pcall (st_LuaCore.pSt_LuaState , 0 , 0 , 0 ))
282+ {
283+ ModulePlugin_IsErrorOccur = TRUE ;
284+ ModulePlugin_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PLUGIN_EXECTION;
285+ return FALSE ;
286+ }
295287
296288 if (0 == lua_getglobal (st_LuaCore.pSt_LuaState , " PluginCore_Init" ))
297289 {
298- return FALSE ;
299- }
300- if (NULL == lParam)
301- {
302- if (LUA_OK != lua_pcall (st_LuaCore.pSt_LuaState , 0 , 1 , 0 ))
303- {
304- return FALSE ;
305- }
306- }
307- else
308- {
309- lua_pushlightuserdata (st_LuaCore.pSt_LuaState , lParam);
310- if (LUA_OK != lua_pcall (st_LuaCore.pSt_LuaState , 1 , 1 , 0 ))
311- {
312- return FALSE ;
313- }
290+ ModulePlugin_IsErrorOccur = TRUE ;
291+ ModulePlugin_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PLUGIN_FPINIT;
292+ return FALSE ;
314293 }
294+
295+ if (LUA_OK != lua_pcall (st_LuaCore.pSt_LuaState , 0 , 1 , 0 ))
296+ {
297+ ModulePlugin_IsErrorOccur = TRUE ;
298+ ModulePlugin_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PLUGIN_EXECTION;
299+ return FALSE ;
300+ }
315301 if (!lua_toboolean (st_LuaCore.pSt_LuaState , -1 ))
316302 {
317- return FALSE ;
303+ ModulePlugin_IsErrorOccur = TRUE ;
304+ ModulePlugin_dwErrorCode = ERROR_XENGINE_APISERVICE_MODULE_PLUGIN_EXECTION;
305+ return FALSE ;
318306 }
307+ lua_pop (st_LuaCore.pSt_LuaState , -1 );
319308
320309 st_csStl.lock ();
321310 stl_MapFrameWork.insert (make_pair (xhNet, st_LuaCore));
0 commit comments