Browse Source

small changes

* show protocol version on background
* make 860 the default protocol
* avoid more crashes on mapview
* activa crash handler by default
Eduardo Bart 9 years ago
parent
commit
58d9426be8

+ 1
- 0
modules/client_background/background.lua View File

@@ -11,6 +11,7 @@ function Background.init()
11 11
   local clientVersionLabel = background:getChildById('clientVersionLabel')
12 12
   clientVersionLabel:setText('OTClient ' .. g_app.getVersion() .. '\n' ..
13 13
                              'Rev  ' .. g_app.getBuildRevision() .. '\n' ..
14
+                             'Protocol  ' .. g_game.getProtocolVersion() .. '\n' ..
14 15
                              'Built on ' .. g_app.getBuildDate())
15 16
 
16 17
   if not g_game.isOnline() then

+ 1
- 1
modules/client_background/background.otui View File

@@ -16,7 +16,7 @@ Panel
16 16
     anchors.right: parent.right
17 17
     anchors.bottom: parent.bottom
18 18
     text-align: center
19
-    height: 48
19
+    text-auto-resize: true
20 20
     width: 120
21 21
     color: #ffffff
22 22
     font: verdana-11px-monochrome

+ 1
- 1
src/framework/CMakeLists.txt View File

@@ -8,7 +8,6 @@ SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}")
8 8
 
9 9
 # framework options
10 10
 OPTION(WINDOWS_CONSOLE "Enables console window on Windows platform" OFF)
11
-OPTION(CRASH_HANDLER "Generate crash reports" OFF)
12 11
 OPTION(USE_OPENGL_ES2 "Use OpenGL ES 2.0 (for mobiles devices)" OFF)
13 12
 SET(BUILD_REVISION "custom" CACHE "Git revision string (intended for releases)" STRING)
14 13
 
@@ -63,6 +62,7 @@ ENDIF()
63 62
 IF(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
64 63
     ADD_DEFINITIONS(-DDEBUG)
65 64
     MESSAGE(STATUS "Debug information: ON")
65
+    OPTION(CRASH_HANDLER "Generate crash reports" ON)
66 66
 ELSE()
67 67
     MESSAGE(STATUS "Debug information: OFF")
68 68
 ENDIF()

+ 1
- 1
src/otclient/CMakeLists.txt View File

@@ -5,7 +5,7 @@ ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6)
5 5
 
6 6
 # otclient options
7 7
 OPTION(BOT_PROTECTION "Enable bot protection" ON)
8
-SET(PROTOCOL 861 CACHE "Protocol version" STRING)
8
+SET(PROTOCOL 860 CACHE "Protocol version" STRING)
9 9
 ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL})
10 10
 MESSAGE(STATUS "Protocol: " ${PROTOCOL})
11 11
 

+ 56
- 46
src/otclient/core/mapview.cpp View File

@@ -40,7 +40,6 @@ MapView::MapView()
40 40
     m_lockedFirstVisibleFloor = -1;
41 41
     m_cachedFirstVisibleFloor = 0;
42 42
     m_cachedLastVisibleFloor = 7;
43
-    m_customCameraPosition.z = 7;
44 43
 
45 44
     Size frameBufferSize(std::min(g_graphics.getMaxTextureSize(), (int)DEFAULT_FRAMBUFFER_WIDTH),
46 45
                          std::min(g_graphics.getMaxTextureSize(), (int)DEFAULT_FRAMBUFFER_HEIGHT));
@@ -472,50 +471,53 @@ int MapView::calcFirstVisibleFloor()
472 471
     } else {
473 472
         Position cameraPosition = getCameraPosition();
474 473
 
475
-        // avoid rendering multifloors in far views
476
-        if(m_viewRange >= FAR_VIEW) {
477
-            z = cameraPosition.z;
478
-        } else {
479
-            // if nothing is limiting the view, the first visible floor is 0
480
-            int firstFloor = 0;
481
-
482
-            // limits to underground floors while under sea level
483
-            if(cameraPosition.z > Otc::SEA_FLOOR)
484
-                firstFloor = std::max(cameraPosition.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::UNDERGROUND_FLOOR);
485
-
486
-            // loop in 3x3 tiles around the camera
487
-            for(int ix = -1; ix <= 1 && firstFloor < cameraPosition.z; ++ix) {
488
-                for(int iy = -1; iy <= 1 && firstFloor < cameraPosition.z; ++iy) {
489
-                    Position pos = cameraPosition.translated(ix, iy);
490
-
491
-                    // process tiles that we can look through, e.g. windows, doors
492
-                    if((ix == 0 && iy == 0) || (/*(std::abs(ix) != std::abs(iy)) && */g_map.isLookPossible(pos))) {
493
-                        Position upperPos = pos;
494
-                        Position coveredPos = pos;
495
-
496
-                        while(coveredPos.coveredUp() && upperPos.up() && upperPos.z >= firstFloor) {
497
-                            // check tiles physically above
498
-                            TilePtr tile = g_map.getTile(upperPos);
499
-                            if(tile && tile->limitsFloorsView()) {
500
-                                firstFloor = upperPos.z + 1;
501
-                                break;
502
-                            }
503
-
504
-                            // check tiles geometrically above
505
-                            tile = g_map.getTile(coveredPos);
506
-                            if(tile && tile->limitsFloorsView()) {
507
-                                firstFloor = coveredPos.z + 1;
508
-                                break;
474
+        // this could happens if the player is not known yet
475
+        if(cameraPosition.isValid()) {
476
+            // avoid rendering multifloors in far views
477
+            if(m_viewRange >= FAR_VIEW) {
478
+                z = cameraPosition.z;
479
+            } else {
480
+                // if nothing is limiting the view, the first visible floor is 0
481
+                int firstFloor = 0;
482
+
483
+                // limits to underground floors while under sea level
484
+                if(cameraPosition.z > Otc::SEA_FLOOR)
485
+                    firstFloor = std::max(cameraPosition.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::UNDERGROUND_FLOOR);
486
+
487
+                // loop in 3x3 tiles around the camera
488
+                for(int ix = -1; ix <= 1 && firstFloor < cameraPosition.z; ++ix) {
489
+                    for(int iy = -1; iy <= 1 && firstFloor < cameraPosition.z; ++iy) {
490
+                        Position pos = cameraPosition.translated(ix, iy);
491
+
492
+                        // process tiles that we can look through, e.g. windows, doors
493
+                        if((ix == 0 && iy == 0) || (/*(std::abs(ix) != std::abs(iy)) && */g_map.isLookPossible(pos))) {
494
+                            Position upperPos = pos;
495
+                            Position coveredPos = pos;
496
+
497
+                            while(coveredPos.coveredUp() && upperPos.up() && upperPos.z >= firstFloor) {
498
+                                // check tiles physically above
499
+                                TilePtr tile = g_map.getTile(upperPos);
500
+                                if(tile && tile->limitsFloorsView()) {
501
+                                    firstFloor = upperPos.z + 1;
502
+                                    break;
503
+                                }
504
+
505
+                                // check tiles geometrically above
506
+                                tile = g_map.getTile(coveredPos);
507
+                                if(tile && tile->limitsFloorsView()) {
508
+                                    firstFloor = coveredPos.z + 1;
509
+                                    break;
510
+                                }
509 511
                             }
510 512
                         }
511 513
                     }
512 514
                 }
515
+                z = firstFloor;
513 516
             }
514
-
515
-            z = firstFloor;
516 517
         }
517 518
     }
518 519
 
520
+    // just ensure the that the floor is in the valid range
519 521
     z = std::min(std::max(z, 0), (int)Otc::MAX_Z);
520 522
     return z;
521 523
 }
@@ -525,17 +527,21 @@ int MapView::calcLastVisibleFloor()
525 527
     int z = 7;
526 528
 
527 529
     Position cameraPosition = getCameraPosition();
528
-    // avoid rendering multifloors in far views
529
-    if(m_viewRange >= FAR_VIEW) {
530
-        z = cameraPosition.z;
531
-    } else {
532
-        // view only underground floors when below sea level
533
-        if(cameraPosition.z > Otc::SEA_FLOOR)
534
-            z = cameraPosition.z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE;
535
-        else
536
-            z = Otc::SEA_FLOOR;
530
+    // this could happens if the player is not known yet
531
+    if(cameraPosition.isValid()) {
532
+        // avoid rendering multifloors in far views
533
+        if(m_viewRange >= FAR_VIEW) {
534
+            z = cameraPosition.z;
535
+        } else {
536
+            // view only underground floors when below sea level
537
+            if(cameraPosition.z > Otc::SEA_FLOOR)
538
+                z = cameraPosition.z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE;
539
+            else
540
+                z = Otc::SEA_FLOOR;
541
+        }
537 542
     }
538 543
 
544
+    // just ensure the that the floor is in the valid range
539 545
     z = std::min(std::max(z, 0), (int)Otc::MAX_Z);
540 546
     return z;
541 547
 }
@@ -553,6 +559,10 @@ TilePtr MapView::getTile(const Point& mousePos, const Rect& mapRect)
553 559
     Size visibleSize = getVisibleSize();
554 560
     Position cameraPosition = getCameraPosition();
555 561
 
562
+    // if we have no camera, its impossible to get the tile
563
+    if(!cameraPosition.isValid())
564
+        return nullptr;
565
+
556 566
     float scaleFactor = m_tileSize / (float)Otc::TILE_PIXELS;
557 567
 
558 568
 

Loading…
Cancel
Save