@@ -453,12 +453,11 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
453
453
int top_lvl2 = lua_gettop (L);
454
454
455
455
if (servers[i][" clients" ].asString ().size ()) {
456
-
457
- const char * clients_raw = servers[i][" clients" ].asString ().c_str ();
456
+ std::string clients_raw = servers[i][" clients" ].asString ();
458
457
char * endptr = 0 ;
459
- int numbervalue = strtol (clients_raw,&endptr,10 );
458
+ int numbervalue = strtol (clients_raw. c_str () ,&endptr,10 );
460
459
461
- if ((* clients_raw != 0 ) && (*endptr == 0 )) {
460
+ if ((clients_raw != " " ) && (*endptr == 0 )) {
462
461
lua_pushstring (L," clients" );
463
462
lua_pushnumber (L,numbervalue);
464
463
lua_settable (L, top_lvl2);
@@ -467,11 +466,11 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
467
466
468
467
if (servers[i][" clients_max" ].asString ().size ()) {
469
468
470
- const char * clients_max_raw = servers[i][" clients_max" ].asString (). c_str ();
469
+ std::string clients_max_raw = servers[i][" clients_max" ].asString ();
471
470
char * endptr = 0 ;
472
- int numbervalue = strtol (clients_max_raw,&endptr,10 );
471
+ int numbervalue = strtol (clients_max_raw. c_str () ,&endptr,10 );
473
472
474
- if ((* clients_max_raw != 0 ) && (*endptr == 0 )) {
473
+ if ((clients_max_raw != " " ) && (*endptr == 0 )) {
475
474
lua_pushstring (L," clients_max" );
476
475
lua_pushnumber (L,numbervalue);
477
476
lua_settable (L, top_lvl2);
@@ -480,7 +479,8 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
480
479
481
480
if (servers[i][" version" ].asString ().size ()) {
482
481
lua_pushstring (L," version" );
483
- lua_pushstring (L,servers[i][" version" ].asString ().c_str ());
482
+ std::string topush = servers[i][" version" ].asString ();
483
+ lua_pushstring (L,topush.c_str ());
484
484
lua_settable (L, top_lvl2);
485
485
}
486
486
@@ -510,25 +510,29 @@ int ModApiMainMenu::l_get_favorites(lua_State *L)
510
510
511
511
if (servers[i][" description" ].asString ().size ()) {
512
512
lua_pushstring (L," description" );
513
- lua_pushstring (L,servers[i][" description" ].asString ().c_str ());
513
+ std::string topush = servers[i][" description" ].asString ();
514
+ lua_pushstring (L,topush.c_str ());
514
515
lua_settable (L, top_lvl2);
515
516
}
516
517
517
518
if (servers[i][" name" ].asString ().size ()) {
518
519
lua_pushstring (L," name" );
519
- lua_pushstring (L,servers[i][" name" ].asString ().c_str ());
520
+ std::string topush = servers[i][" name" ].asString ();
521
+ lua_pushstring (L,topush.c_str ());
520
522
lua_settable (L, top_lvl2);
521
523
}
522
524
523
525
if (servers[i][" address" ].asString ().size ()) {
524
526
lua_pushstring (L," address" );
525
- lua_pushstring (L,servers[i][" address" ].asString ().c_str ());
527
+ std::string topush = servers[i][" address" ].asString ();
528
+ lua_pushstring (L,topush.c_str ());
526
529
lua_settable (L, top_lvl2);
527
530
}
528
531
529
532
if (servers[i][" port" ].asString ().size ()) {
530
533
lua_pushstring (L," port" );
531
- lua_pushstring (L,servers[i][" port" ].asString ().c_str ());
534
+ std::string topush = servers[i][" port" ].asString ();
535
+ lua_pushstring (L,topush.c_str ());
532
536
lua_settable (L, top_lvl2);
533
537
}
534
538
0 commit comments