mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Move all temporary variables off of entityclass
This is a refactor that simply moves all temporary variables off of entityclass, and makes it so they are no longer global variables. This makes the resulting code easier to understand as it is less entangled with global state. These attributes were: - colpoint1 - colpoint2 - tempx - tempy - tempw - temph - temp - temp2 - tpx1 - tpy1 - tpx2 - tpy2 - temprect - temprect2 - x (actually unused) - dx - dy - dr - px - py - linetemp - activetrigger - skipblocks - skipdirblocks Most of these attributes were assigned before any of the times they were used, so it's easy to prove that ungloballing them won't change any behaviors. However, dx, dy, dr, and skipblocks are a bit more tricky to analyze. They relate to blocks, with dx, dy, and dr more specifically relating to one-way tiles. So after some testing with the quirks of one-way tiles, it seems that the jankiness of one-way tiles haven't changed at all, either. Unfortunately, the attribute k is clearly used without being assigned beforehand, so I can't move it off of entityclass. It's the same story with the attribute k that Graphics has, too.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef ENTITY_H
|
||||
#define ENTITY_H
|
||||
|
||||
#include <SDL.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -94,31 +95,26 @@ public:
|
||||
|
||||
int getteleporter();
|
||||
|
||||
void rectset(int xi, int yi, int wi, int hi);
|
||||
|
||||
void rect2set(int xi, int yi, int wi, int hi);
|
||||
|
||||
bool entitycollide(int a, int b);
|
||||
|
||||
bool checkdamage(bool scm = false);
|
||||
|
||||
void settemprect(int t);
|
||||
|
||||
int checktrigger(int* block_idx);
|
||||
|
||||
int checkactivity();
|
||||
|
||||
int getgridpoint(int t);
|
||||
|
||||
bool checkplatform();
|
||||
bool checkplatform(const SDL_Rect& temprect, int* px, int* py);
|
||||
|
||||
bool checkblocks();
|
||||
bool checkblocks(const SDL_Rect& temprect, const float dx, const float dy, const float dr, const bool skipdirblocks);
|
||||
|
||||
bool checktowerspikes(int t);
|
||||
|
||||
bool checkwall();
|
||||
bool checkwall(const SDL_Rect& temprect, const float dx, const float dy, const float dr, const bool skipblocks, const bool skipdirblocks);
|
||||
bool checkwall(const SDL_Rect& temprect);
|
||||
|
||||
float hplatformat();
|
||||
float hplatformat(const int px, const int py);
|
||||
|
||||
int yline(int a, int b);
|
||||
|
||||
@@ -139,7 +135,7 @@ public:
|
||||
|
||||
bool entitycollideroof(int t);
|
||||
|
||||
bool testwallsx(int t, int tx, int ty);
|
||||
bool testwallsx(int t, int tx, int ty, const bool skipdirblocks);
|
||||
|
||||
bool testwallsy(int t, float tx, float ty);
|
||||
|
||||
@@ -167,19 +163,7 @@ public:
|
||||
|
||||
std::vector<entclass> linecrosskludge;
|
||||
|
||||
point colpoint1, colpoint2;
|
||||
|
||||
int tempx, tempy, tempw, temph, temp, temp2;
|
||||
//public var tempx:int, tempy:int, tempw:int, temph:int, temp:int, temp2:int;
|
||||
int tpx1, tpy1, tpx2, tpy2;
|
||||
|
||||
SDL_Rect temprect, temprect2;
|
||||
|
||||
int x, k;
|
||||
float dx, dy, dr;
|
||||
|
||||
int px, py, linetemp;
|
||||
int activetrigger;
|
||||
int k;
|
||||
|
||||
|
||||
std::vector<blockclass> blocks;
|
||||
@@ -187,8 +171,6 @@ public:
|
||||
bool collect[100];
|
||||
bool customcollect[100];
|
||||
|
||||
bool skipblocks, skipdirblocks;
|
||||
|
||||
int platformtile;
|
||||
bool vertplatforms, horplatforms;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user