Skip to content

Commit

Permalink
Fixing Issues...
Browse files Browse the repository at this point in the history
- #672 (default user:// in $HOME/.godot/app_userdata (linux/osx) and $APPDATA/Godot/app_userdata (Windows)
- #676 (draw both tiles and octants in order from top to bottom, left to right )
- #686 (unicode escape sequences work now)
- #702 (was not a bug, but a test was added to see if bodies went too far away)
  • Loading branch information
reduz committed Sep 19, 2014
1 parent 526aae6 commit 549d344
Show file tree
Hide file tree
Showing 22 changed files with 503 additions and 178 deletions.
1 change: 1 addition & 0 deletions core/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,7 @@ Globals::Globals() {
set("application/main_scene","");
custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"xml,res,scn,xscn");
set("application/disable_stdout",false);
set("application/use_shared_user_dir",true);


key.key.scancode=KEY_RETURN;
Expand Down
45 changes: 28 additions & 17 deletions core/os/dir_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,35 +130,46 @@ Error DirAccess::make_dir_recursive(String p_dir) {
if (p_dir.length() < 1) {
return OK;
};

String full_dir;
Globals* g = Globals::get_singleton();
String cur = normalize_path(g->globalize_path(get_current_dir()));
if (cur[cur.length()-1] != '/') {
cur = cur + "/";
};

String dir = normalize_path(g->globalize_path(p_dir));
if (dir.length() < 1) {
return OK;
};
if (dir[dir.length()-1] != '/') {
dir = dir + "/";
};
if (!p_dir.is_abs_path()) {
//append current

ERR_FAIL_COND_V(dir.find(cur) != 0, FAILED);
String cur = normalize_path(g->globalize_path(get_current_dir()));
if (cur[cur.length()-1] != '/') {
cur = cur + "/";
};

full_dir=(cur+"/"+p_dir).simplify_path();
} else {
//validate and use given
String dir = normalize_path(g->globalize_path(p_dir));
if (dir.length() < 1) {
return OK;
};
if (dir[dir.length()-1] != '/') {
dir = dir + "/";
};
full_dir=dir;
}

String rel = dir.substr(cur.length(), (dir.length() - cur.length()));
int slices = full_dir.get_slice_count("/");

int pos = 0;
while (pos < rel.length()) {
while (pos < full_dir.length()) {

int n = rel.find("/", pos);
int n = full_dir.find("/", pos);
if (n < 0) {
n = rel.length();
n = full_dir.length();
};
pos = n + 1;

if (pos > 1) {
Error err = make_dir(rel.substr(0, pos -1));
String to_create = full_dir.substr(0, pos -1);
//print_line("MKDIR: "+to_create);
Error err = make_dir(to_create);
if (err != OK && err != ERR_ALREADY_EXISTS) {

ERR_FAIL_V(err);
Expand Down
2 changes: 1 addition & 1 deletion core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ void OS::_ensure_data_dir() {
}

da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
Error err = da->make_dir(dd);
Error err = da->make_dir_recursive(dd);
if (err!=OK) {
ERR_EXPLAIN("Error attempting to create data dir: "+dd);
}
Expand Down
56 changes: 36 additions & 20 deletions demos/2d/particles/particles.xml

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion drivers/unix/os_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,15 @@ String OS_Unix::get_data_dir() const {
String an = Globals::get_singleton()->get("application/name");
if (an!="") {



if (has_environment("HOME")) {

return get_environment("HOME")+"/."+an;
bool use_godot = Globals::get_singleton()->get("application/use_shared_user_dir");
if (use_godot)
return get_environment("HOME")+"/.godot/app_userdata/"+an;
else
return get_environment("HOME")+"/."+an;
}
}

Expand Down
8 changes: 8 additions & 0 deletions modules/gdscript/gd_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2089,6 +2089,7 @@ void GDParser::_parse_class(ClassNode *p_class) {

current_export=PropertyInfo();
_set_error("Expected a string constant in enumeration hint.");
return;
}

String c = tokenizer->get_token_constant();
Expand All @@ -2106,6 +2107,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token()!=GDTokenizer::TK_COMMA) {
current_export=PropertyInfo();
_set_error("Expected ')' or ',' in enumeration hint.");
return;
}

tokenizer->advance();
Expand All @@ -2122,6 +2124,7 @@ void GDParser::_parse_class(ClassNode *p_class) {

current_export=PropertyInfo();
_set_error("Expected a range in numeric hint.");
return;

}
//enumeration
Expand All @@ -2139,6 +2142,7 @@ void GDParser::_parse_class(ClassNode *p_class) {

current_export=PropertyInfo();
_set_error("Expected ',' or ')' in numeric range hint.");
return;
}

tokenizer->advance();
Expand All @@ -2147,6 +2151,7 @@ void GDParser::_parse_class(ClassNode *p_class) {

current_export=PropertyInfo();
_set_error("Expected a number as upper bound in numeric range hint.");
return;
}

current_export.hint_string+=","+tokenizer->get_token_constant().operator String();
Expand All @@ -2159,6 +2164,7 @@ void GDParser::_parse_class(ClassNode *p_class) {

current_export=PropertyInfo();
_set_error("Expected ',' or ')' in numeric range hint.");
return;
}

tokenizer->advance();
Expand All @@ -2167,6 +2173,7 @@ void GDParser::_parse_class(ClassNode *p_class) {

current_export=PropertyInfo();
_set_error("Expected a number as step in numeric range hint.");
return;
}

current_export.hint_string+=","+tokenizer->get_token_constant().operator String();
Expand All @@ -2185,6 +2192,7 @@ void GDParser::_parse_class(ClassNode *p_class) {

current_export=PropertyInfo();
_set_error("Expected a string constant in enumeration hint.");
return;
}

String c = tokenizer->get_token_constant();
Expand Down
22 changes: 10 additions & 12 deletions modules/gdscript/gd_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,22 +565,21 @@ void GDTokenizerText::_advance() {
case '\'': res='\''; break;
case '\"': res='\"'; break;
case '\\': res='\\'; break;
case 'x': {
//hexnumbarh - oct is deprecated
case '/': res='/'; break; //wtf

int read=0;
case 'u': {
//hexnumbarh - oct is deprecated
i+=1;
for(int j=0;j<4;j++) {
CharType c = GETCHAR(i+j);
if (c==0) {
_make_error("Unterminated String");
return;
}
if (!_is_hex(c)) {
if (j==0 || !(j&1)) {
_make_error("Malformed hex constant in string");
return;
} else
break;
if (!((c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F'))) {

_make_error("Malformed hex constant in string");
return;
}
CharType v;
if (c>='0' && c<='9') {
Expand All @@ -599,10 +598,9 @@ void GDTokenizerText::_advance() {
res<<=4;
res|=v;

read++;
}
i+=read-1;

}
i+=3;

} break;
default: {
Expand Down
6 changes: 5 additions & 1 deletion platform/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,11 @@ String OS_Windows::get_data_dir() const {

if (has_environment("APPDATA")) {

return (OS::get_singleton()->get_environment("APPDATA")+"\\"+an).replace("\\","/"); // windows path to unix path to be consistent with get_resource_path
bool use_godot = Globals::get_singleton()->get("application/use_shared_user_dir");
if (use_godot)
return (OS::get_singleton()->get_environment("APPDATA")+"/"+an).replace("\\","/");
else
return (OS::get_singleton()->get_environment("APPDATA")+"/Godot/app_userdata/"+an).replace("\\","/");
}
}

Expand Down
8 changes: 6 additions & 2 deletions scene/2d/particles_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void Particles2D::_process_particles(float p_delta) {
p.velocity*=param[PARAM_LINEAR_VELOCITY]+param[PARAM_LINEAR_VELOCITY]*_rand_from_seed(&rand_seed)*randomness[PARAM_LINEAR_VELOCITY];
p.velocity+=initial_velocity;
p.active=true;
p.rot=0;
p.rot=Math::deg2rad(param[PARAM_INITIAL_ANGLE]+param[PARAM_INITIAL_ANGLE]*randomness[PARAM_INITIAL_ANGLE]*_rand_from_seed(&rand_seed));
active_count++;


Expand Down Expand Up @@ -632,6 +632,7 @@ static const char* _particlesframe_property_names[Particles2D::PARAM_MAX]={
"params/radial_accel",
"params/tangential_accel",
"params/damping",
"params/initial_angle",
"params/initial_size",
"params/final_size",
"params/hue_variation"
Expand All @@ -647,7 +648,8 @@ static const char* _particlesframe_property_rnames[Particles2D::PARAM_MAX]={
"randomness/gravity_strength",
"randomness/radial_accel",
"randomness/tangential_accel",
"randomness/damping",
"randomness/damping",
"randomness/initial_angle",
"randomness/initial_size",
"randomness/final_size",
"randomness/hue_variation"
Expand All @@ -664,6 +666,7 @@ static const char* _particlesframe_property_ranges[Particles2D::PARAM_MAX]={
"-128,128,0.01",
"-128,128,0.01",
"0,1024,0.001",
"0,360,0.01",
"0,1024,0.01",
"0,1024,0.01",
"0,1,0.01"
Expand Down Expand Up @@ -1041,6 +1044,7 @@ Particles2D::Particles2D() {
set_param(PARAM_GRAVITY_STRENGTH,9.8);
set_param(PARAM_RADIAL_ACCEL,0);
set_param(PARAM_TANGENTIAL_ACCEL,0);
set_param(PARAM_INITIAL_ANGLE,0.0);
set_param(PARAM_INITIAL_SIZE,1.0);
set_param(PARAM_FINAL_SIZE,1.0);

Expand Down
3 changes: 2 additions & 1 deletion scene/2d/particles_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ class Particles2D : public Node2D {
enum Parameter {
PARAM_DIRECTION,
PARAM_SPREAD,
PARAM_LINEAR_VELOCITY,
PARAM_LINEAR_VELOCITY,
PARAM_SPIN_VELOCITY,
PARAM_ORBIT_VELOCITY,
PARAM_GRAVITY_DIRECTION,
PARAM_GRAVITY_STRENGTH,
PARAM_RADIAL_ACCEL,
PARAM_TANGENTIAL_ACCEL,
PARAM_DAMPING,
PARAM_INITIAL_ANGLE,
PARAM_INITIAL_SIZE,
PARAM_FINAL_SIZE,
PARAM_HUE_VARIATION,
Expand Down
20 changes: 19 additions & 1 deletion scene/2d/tile_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ void TileMap::_update_dirty_quadrants() {

pending_update=false;

if (quadrant_order_dirty) {

for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {

Quadrant &q=E->get();
if (q.canvas_item.is_valid()) {
VS::get_singleton()->canvas_item_raise(q.canvas_item);
}

}

quadrant_order_dirty=false;
}

_recompute_rect_cache();

}
Expand Down Expand Up @@ -329,6 +343,7 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const
q.pos=Vector2(p_qk.x,p_qk.y)*quadrant_size*cell_size;

rect_cache_dirty=true;
quadrant_order_dirty=true;
return quadrant_map.insert(p_qk,q);
}

Expand Down Expand Up @@ -387,8 +402,9 @@ void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y) {

if (!E) {
E=tile_map.insert(pk,Cell());
if (!Q)
if (!Q) {
Q=_create_quadrant(qk);
}
Quadrant &q=Q->get();
q.cells.insert(pk);
} else {
Expand Down Expand Up @@ -510,6 +526,7 @@ void TileMap::_set_tile_data(const DVector<int>& p_data) {
// if (x<-20 || y <-20 || x>4000 || y>4000)
// continue;
set_cell(x,y,v,flip_h,flip_v);

}

}
Expand Down Expand Up @@ -658,6 +675,7 @@ TileMap::TileMap() {

rect_cache_dirty=true;
pending_update=false;
quadrant_order_dirty=false;
quadrant_size=16;
cell_size=64;
center_x=false;
Expand Down
8 changes: 5 additions & 3 deletions scene/2d/tile_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ class TileMap : public Node2D {
int16_t x;
int16_t y;
};

uint32_t key;
bool operator<(const PosKey& pk) const { return key<pk.key; }

//using a more precise comparison so the regions can be sorted later
bool operator<(const PosKey& p_k) const { return (y==p_k.y) ? x < p_k.x : y < p_k.y; }

PosKey(int16_t p_x, int16_t p_y) { x=p_x; y=p_y; }
PosKey() { key=0; }
PosKey() { x=0; y=0; }

};

Expand Down Expand Up @@ -97,6 +98,7 @@ class TileMap : public Node2D {

Rect2 rect_cache;
bool rect_cache_dirty;
bool quadrant_order_dirty;
float fp_adjust;
float friction;
float bounce;
Expand Down
12 changes: 10 additions & 2 deletions scene/3d/spatial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,12 @@ Ref<SpatialGizmo> Spatial::get_gizmo() const {
void Spatial::_update_gizmo() {

data.gizmo_dirty=false;
if (data.gizmo.is_valid())
data.gizmo->redraw();
if (data.gizmo.is_valid()) {
if (is_visible())
data.gizmo->redraw();
else
data.gizmo->clear();
}
}


Expand Down Expand Up @@ -511,6 +515,10 @@ void Spatial::_propagate_visibility_changed() {
notification(NOTIFICATION_VISIBILITY_CHANGED);
emit_signal(SceneStringNames::get_singleton()->visibility_changed);
_change_notify("visibility/visible");
#ifdef TOOLS_ENABLED
if (data.gizmo.is_valid())
_update_gizmo();
#endif

for (List<Spatial*>::Element*E=data.children.front();E;E=E->next()) {

Expand Down
1 change: 1 addition & 0 deletions scene/3d/spatial.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SpatialGizmo : public Reference {

virtual void create()=0;
virtual void transform()=0;
virtual void clear()=0;
virtual void redraw()=0;
virtual void free()=0;

Expand Down
Loading

0 comments on commit 549d344

Please sign in to comment.