Skip to content

Commit dc64f32

Browse files
committed
Merge remote-tracking branch 'upstream/master' into loadout_copy_paste
2 parents d372319 + 8bcafea commit dc64f32

17 files changed

Lines changed: 149 additions & 85 deletions

src/Battlescape/BattlescapeState.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ namespace OpenXcom
9494
BattlescapeState::BattlescapeState(Game *game) : State(game), _popups(), _xBeforeMouseScrolling(0), _yBeforeMouseScrolling(0), _totalMouseMoveX(0), _totalMouseMoveY(0), _mouseMovedOverThreshold(0)
9595
{
9696
std::fill_n(_visibleUnit, 10, (BattleUnit*)(0));
97-
//game->getScreen()->setScale(1.0);
97+
9898
int screenWidth = Options::baseXResolution;
9999
int screenHeight = Options::baseYResolution;
100100
int iconsWidth = 320;

src/Battlescape/Map.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace OpenXcom
7878
* @param y Y position in pixels.
7979
* @param visibleMapHeight Current visible map height.
8080
*/
81-
Map::Map(Game *game, int width, int height, int x, int y, int visibleMapHeight) : InteractiveSurface(width, height, x, y), _game(game), _arrow(0), _selectorX(0), _selectorY(0), _mouseX(0), _mouseY(0), _cursorType(CT_NORMAL), _cursorSize(1), _animFrame(0), _projectile(0), _projectileInFOV(false), _explosionInFOV(false), _visibleMapHeight(visibleMapHeight), _unitDying(false), _smoothingEngaged(false)
81+
Map::Map(Game *game, int width, int height, int x, int y, int visibleMapHeight) : InteractiveSurface(width, height, x, y), _game(game), _arrow(0), _selectorX(0), _selectorY(0), _mouseX(0), _mouseY(0), _cursorType(CT_NORMAL), _cursorSize(1), _animFrame(0), _projectile(0), _projectileInFOV(false), _explosionInFOV(false), _launch(false), _visibleMapHeight(visibleMapHeight), _unitDying(false), _smoothingEngaged(false)
8282
{
8383
_previewSetting = Options::battleNewPreviewPath;
8484
_smoothCamera = Options::battleSmoothCamera;
@@ -289,15 +289,20 @@ void Map::drawTerrain(Surface *surface)
289289
}
290290
if (_smoothCamera)
291291
{
292+
if (_launch)
293+
{
294+
_launch = false;
295+
if ((bulletPositionScreen.x < 1 || bulletPositionScreen.x > surface->getWidth() - 1 ||
296+
bulletPositionScreen.y < 1 || bulletPositionScreen.y > _visibleMapHeight - 1))
297+
{
298+
_camera->centerOnPosition(Position(bulletLowX, bulletLowY, bulletHighZ), false);
299+
_camera->convertVoxelToScreen(_projectile->getPosition(), &bulletPositionScreen);
300+
}
301+
}
292302
if (!_smoothingEngaged)
293303
{
294-
Position origin = _projectile->getOrigin();
295-
Position target = _projectile->getTarget();
296-
if (std::abs(origin.x - target.x) > 1 ||
297-
std::abs(origin.y - target.y) > 1 ||
298-
std::abs(origin.z - target.z) > 1 ||
299-
bulletPositionScreen.x < 0 || bulletPositionScreen.x > surface->getWidth() ||
300-
bulletPositionScreen.y < 0 || bulletPositionScreen.y > _visibleMapHeight)
304+
if (bulletPositionScreen.x < 1 || bulletPositionScreen.x > surface->getWidth() - 1 ||
305+
bulletPositionScreen.y < 1 || bulletPositionScreen.y > _visibleMapHeight - 1)
301306
{
302307
_smoothingEngaged = true;
303308
}
@@ -1205,6 +1210,10 @@ void Map::cacheUnit(BattleUnit *unit)
12051210
void Map::setProjectile(Projectile *projectile)
12061211
{
12071212
_projectile = projectile;
1213+
if (projectile && Options::battleSmoothCamera)
1214+
{
1215+
_launch = true;
1216+
}
12081217
}
12091218

12101219
/**

src/Battlescape/Map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Map : public InteractiveSurface
6363
Projectile *_projectile;
6464
bool _projectileInFOV;
6565
std::set<Explosion *> _explosions;
66-
bool _explosionInFOV;
66+
bool _explosionInFOV, _launch;
6767
BattlescapeMessage *_message;
6868
Camera *_camera;
6969
int _visibleMapHeight;

src/Battlescape/TileEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ bool TileEngine::detonate(Tile* tile)
13801380
}
13811381
}
13821382
}
1383-
if (2 * flam < remainingPower && (tiles[i]->getMapData(MapData::O_FLOOR) || tiles[i]->getMapData(MapData::O_OBJECT)))
1383+
if (i > 3 && 2 * flam < remainingPower && (tile->getMapData(MapData::O_FLOOR) || tile->getMapData(MapData::O_OBJECT)))
13841384
{
13851385
tile->setFire(fuel);
13861386
tile->setSmoke(std::max(1, std::min(15 - (flam / 10), 12)));

src/Battlescape/UnitDieBState.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void UnitDieBState::init()
112112
*/
113113
void UnitDieBState::think()
114114
{
115-
if (_unit->getDirection() != 3)
115+
if (_unit->getDirection() != 3 && _damageType != DT_HE)
116116
{
117117
int dir = _unit->getDirection() + 1;
118118
if (dir == 8)

src/Engine/Game.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Game::Game(const std::string &title) : _screen(0), _cursor(0), _lang(0), _states
6060
}
6161
Log(LOG_INFO) << "SDL initialized successfully.";
6262

63+
Options::reload = false;
6364
Options::mute = false;
6465
// Initialize SDL_mixer
6566
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)

src/Engine/Options.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ void create()
7878
_info.push_back(OptionInfo("spendResearchedItems", &spendResearchedItems, false));
7979
_info.push_back(OptionInfo("baseXResolution", &baseXResolution, Screen::ORIGINAL_WIDTH));
8080
_info.push_back(OptionInfo("baseYResolution", &baseYResolution, Screen::ORIGINAL_HEIGHT));
81+
_info.push_back(OptionInfo("baseResGeoscape", &baseResGeoscape, true));
82+
_info.push_back(OptionInfo("baseResBasescape", &baseResBasescape, true));
83+
_info.push_back(OptionInfo("baseResBattlescape", &baseResBattlescape, true));
8184
_info.push_back(OptionInfo("useScaleFilter", &useScaleFilter, false));
8285
_info.push_back(OptionInfo("useHQXFilter", &useHQXFilter, false));
8386
_info.push_back(OptionInfo("useOpenGL", &useOpenGL, false));

src/Engine/Options.inc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ OPT int displayWidth, displayHeight, maxFrameSkip, baseXResolution, baseYResolut
66
audioSampleRate, audioBitDepth, pauseMode, windowedModePositionX, windowedModePositionY, FPS, changeValueByMouseWheel;
77
OPT bool fullscreen, asyncBlit, playIntro, useScaleFilter, useHQXFilter, useOpenGL, checkOpenGLErrors, vSyncForOpenGL, useOpenGLSmoothing,
88
allowResize, borderless, debug, debugUi, fpsCounter, newSeedOnLoad, keepAspectRatio,
9-
cursorInBlackBandsInFullscreen, cursorInBlackBandsInWindow, cursorInBlackBandsInBorderlessWindow;
9+
cursorInBlackBandsInFullscreen, cursorInBlackBandsInWindow, cursorInBlackBandsInBorderlessWindow,
10+
baseResGeoscape, baseResBasescape, baseResBattlescape;
1011
OPT std::string language, useOpenGLShader;
1112
OPT KeyboardType keyboardMode;
1213
OPT SaveSort saveOrder;

src/Geoscape/Cord.h

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,38 @@
2020
#define OPENXCOM_CORD_H
2121

2222
#include <cmath>
23+
#include "../aresame.h"
2324

2425
namespace OpenXcom
2526
{
26-
27-
27+
struct Cord;
28+
29+
struct CordPolar
30+
{
31+
double lon, lat;
32+
33+
inline CordPolar(double plon, double plat)
34+
{
35+
lon = plon;
36+
lat = plat;
37+
}
38+
inline CordPolar(const CordPolar& pol)
39+
{
40+
lon = pol.lon;
41+
lat = pol.lat;
42+
}
43+
inline CordPolar()
44+
{
45+
lon = 0;
46+
lat = 0;
47+
}
48+
explicit inline CordPolar(const Cord&);
49+
};
50+
2851
struct Cord
2952
{
3053
double x, y, z;
31-
54+
3255
inline Cord(double px, double py, double pz)
3356
{
3457
x = px;
@@ -47,7 +70,16 @@ struct Cord
4770
y = 0.0;
4871
z = 0.0;
4972
}
50-
73+
explicit inline Cord(const CordPolar&);
74+
75+
inline Cord operator +()
76+
{
77+
return *this;
78+
}
79+
inline Cord operator -()
80+
{
81+
return Cord(-x, -y, -z);
82+
}
5183
inline Cord& operator *=(double d)
5284
{
5385
x *= d;
@@ -77,12 +109,31 @@ struct Cord
77109
z -= c.z;
78110
return *this;
79111
}
112+
inline bool operator ==(const Cord& c)
113+
{
114+
return AreSame(x, c.x) && AreSame(y, c.y) && AreSame(z, c.z);
115+
}
116+
80117
inline double norm() const
81118
{
82-
return std::sqrt(x*x+ y*y + z*z);
119+
return std::sqrt(x*x + y*y + z*z);
83120
}
84121
};
85122

123+
inline Cord::Cord(const CordPolar& pol)
124+
{
125+
x = std::sin(pol.lon) * std::cos(pol.lat);
126+
y = std::sin(pol.lat);
127+
z = std::cos(pol.lon) * std::cos(pol.lat);
128+
}
129+
130+
inline CordPolar::CordPolar(const Cord& c)
131+
{
132+
double inv = 1/c.norm();
133+
lat = asin(c.y * inv);
134+
lon = atan2(c.x, c.z);
135+
}
136+
86137
}//namespace OpenXcom
87138
#endif /* OPENXCOM_CORD_H */
88139

src/Geoscape/Globe.cpp

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,9 +1149,9 @@ void Globe::XuLine(Surface* surface, Surface* src, double x1, double y1, double
11491149

11501150
while(len>0)
11511151
{
1152-
if (x0>0 && y0>0 && x0<surface->getWidth() && y0<surface->getHeight())
1152+
tcol=src->getPixel((int)x0,(int)y0);
1153+
if (tcol)
11531154
{
1154-
tcol=src->getPixel((int)x0,(int)y0);
11551155
const int d = tcol & helper::ColorGroup;
11561156
if(d == Palette::blockOffset(12) || d == Palette::blockOffset(13))
11571157
{
@@ -1523,57 +1523,39 @@ void Globe::drawDetail()
15231523

15241524
void Globe::drawPath(Surface *surface, double lon1, double lat1, double lon2, double lat2)
15251525
{
1526-
double sx = lon2 - lon1;
1527-
double sy = lat2 - lat1;
1528-
double ln1, lt1, ln2, lt2, dln, dlt;
1529-
double slen, dlen;
1530-
int seg;
1526+
double length;
1527+
Sint16 count;
15311528
Sint16 x1, y1, x2, y2;
1529+
CordPolar p1, p2;
1530+
Cord a(CordPolar(lon1, lat1));
1531+
Cord b(CordPolar(lon2, lat2));
15321532

1533-
if (sx<0) sx += 2*M_PI;
1534-
1535-
if (fabs(sx)<0.01)
1536-
{
1537-
seg = abs( sy/(2*M_PI)*48 );
1538-
if (seg == 0) ++seg;
1539-
}
1540-
else
1541-
{
1542-
seg = abs( sx/(2*M_PI)*96 );
1543-
if (seg == 0) ++seg;
1544-
}
1545-
sx /= seg;
1546-
sy /= seg;
1547-
slen = sqrt(sx * sx + sy * sy);
1533+
if(-b == a)
1534+
return;
15481535

1549-
ln2 = lon1;
1550-
lt2 = lat1;
1536+
b -= a;
15511537

1552-
for (int i = 0; i < seg; ++i)
1538+
//longer path have more parts
1539+
length = b.norm();
1540+
length *= length*15;
1541+
count = length + 1;
1542+
b /= count;
1543+
p1 = CordPolar(a);
1544+
polarToCart(p1.lon, p1.lat, &x1, &y1);
1545+
for(int i = 0; i < count; ++i)
15531546
{
1554-
ln1 = ln2;
1555-
lt1 = lt2;
1556-
dln = sin(lon2 - ln1) * cos(lat2);
1557-
dlt = cos(lt1) * sin(lat2) - sin(lt1) * cos(lat2) * cos(lon2 - ln1);
1558-
dlen = sqrt(dln * dln + dlt * dlt);
1559-
dlt = dlt / dlen * slen;
1560-
dln = dln / dlen * slen / cos(lt1 + dlt);
1561-
ln2 = ln1 + dln;
1562-
lt2 = lt2 + dlt;
1563-
1564-
if (M_PI - fabs(fabs(lon2 - ln2) - M_PI) < 0.05 && M_PI - fabs(fabs(lat2 - lt2) - M_PI) < 0.05)
1565-
{
1566-
ln2 = lon2;
1567-
lt2 = lat2;
1568-
i = seg;
1569-
}
1547+
a += b;
1548+
p2 = CordPolar(a);
1549+
polarToCart(p2.lon, p2.lat, &x2, &y2);
15701550

1571-
if (!pointBack(ln2, lt2) && !pointBack(ln1, lt1))
1551+
if (!pointBack(p1.lon, p1.lat) && !pointBack(p2.lon, p2.lat))
15721552
{
1573-
polarToCart(ln1,lt1,&x1,&y1);
1574-
polarToCart(ln2,lt2,&x2,&y2);
15751553
XuLine(surface, this, x1, y1, x2, y2, 8);
15761554
}
1555+
1556+
p1 = p2;
1557+
x1 = x2;
1558+
y1 = y2;
15771559
}
15781560
}
15791561

0 commit comments

Comments
 (0)