mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
Add a simple python script to check for common formatting errors (tabs and line endings) and fix existing problems.
a step towards #315
This commit is contained in:
parent
5b76d2c33c
commit
aba651a998
@ -50,7 +50,7 @@ sudo apt install libgl-dev libasound2-dev libx11-dev libxcursor-dev libxrandr-de
|
||||
|
||||
# Contributing
|
||||
### Code
|
||||
Try to follow the style of the existing code. `// TODO: Add a style guide` <br>
|
||||
Try to follow the style of the existing code. The `check_format.py` file can be used to find violations of indentation and line endings. `// TODO: Add a full style guide` <br>
|
||||
If you have any more questions, you can ask them over on [Discord](https://discord.gg/XtqCRRG).
|
||||
### Textures
|
||||
If you want to add new textures, make sure they fit the style of the game.
|
||||
|
@ -1,6 +1,5 @@
|
||||
#version 430
|
||||
out vec4 fragColor;
|
||||
|
||||
in vec2 texCoords;
|
||||
|
||||
uniform sampler2D color;
|
||||
|
@ -30,7 +30,7 @@ vec3 calcLight(int srgb) {
|
||||
void main() {
|
||||
vec4 mvPos = viewMatrix * vec4(position, 1);
|
||||
gl_Position = projectionMatrix * mvPos;
|
||||
outTexCoord = texCoord;
|
||||
mvVertexPos = mvPos.xyz;
|
||||
outTexCoord = texCoord;
|
||||
mvVertexPos = mvPos.xyz;
|
||||
outLight = calcLight(light);
|
||||
}
|
@ -7,7 +7,7 @@ in vec2 unitPosition;
|
||||
|
||||
// Like smooth step, but with linear interpolation instead of s-curve.
|
||||
float linearstep(float edge0, float edge1, float x) {
|
||||
return clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
|
||||
return clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
|
||||
}
|
||||
|
||||
void main(){
|
||||
|
@ -14,8 +14,8 @@ layout(std430, binding = 5) buffer _data
|
||||
|
||||
|
||||
void main() {
|
||||
float x = gl_VertexID;
|
||||
float y = -data[(gl_VertexID+offset)%points];
|
||||
float x = gl_VertexID;
|
||||
float y = -data[(gl_VertexID+offset)%points];
|
||||
// Convert to opengl coordinates:
|
||||
vec2 position_percentage = (start + dimension*vec2(x/points, y))/screen;
|
||||
|
||||
|
@ -204,7 +204,7 @@ void mainBlockDrop() {
|
||||
|
||||
layout(std430, binding = 2) buffer _itemVoxelModels
|
||||
{
|
||||
uint itemVoxelModels[];
|
||||
uint itemVoxelModels[];
|
||||
};
|
||||
|
||||
uint getVoxel(uvec3 pos) {
|
||||
|
@ -20,7 +20,7 @@ uniform float sizeScale;
|
||||
|
||||
layout(std430, binding = 2) buffer _itemVoxelModels
|
||||
{
|
||||
uint itemVoxelModels[];
|
||||
uint itemVoxelModels[];
|
||||
};
|
||||
|
||||
#define modelSize 16
|
||||
|
@ -1,6 +1,6 @@
|
||||
#version 430
|
||||
out vec4 fragColor;
|
||||
|
||||
|
||||
in vec2 texCoords;
|
||||
|
||||
uniform sampler2D color;
|
||||
|
43
format_check.py
Normal file
43
format_check.py
Normal file
@ -0,0 +1,43 @@
|
||||
import os
|
||||
|
||||
import sys
|
||||
|
||||
directory = os.fsencode(".")
|
||||
|
||||
fails = 0
|
||||
|
||||
for subdir, dirs, files in os.walk("."):
|
||||
for file in files:
|
||||
#print os.path.join(subdir, file)
|
||||
filepath = subdir + os.sep + file
|
||||
if filepath.startswith("./compiler"): continue
|
||||
if filepath.startswith("./saves"): continue
|
||||
if filepath.startswith("./serverAssets"): continue
|
||||
if filepath.startswith("./zig-cache"): continue
|
||||
|
||||
if filepath.endswith(".json") or filepath.endswith(".zig") or filepath.endswith(".py") or filepath.endswith(".zon") or filepath.endswith(".vs") or filepath.endswith(".fs") or filepath.endswith(".glsl"):
|
||||
with open(filepath, "r") as f:
|
||||
string = f.read()
|
||||
line = 1
|
||||
lineStart = True
|
||||
for i, c in enumerate(string):
|
||||
if(c == '\r'):
|
||||
print("Incorrect line ending \\r in file ", filepath, " in line ", line, ". Please configure your editor to use LF instead of CRLF.")
|
||||
fails += 1
|
||||
elif(c == '\n'):
|
||||
line += 1
|
||||
lineStart = True
|
||||
elif(c == ' '):
|
||||
if(lineStart):
|
||||
print("Incorrect indentation in file ", filepath, " in line ", line, ". Please use tabs instead of spaces.")
|
||||
fails += 1
|
||||
lineStart = False # avoid repeating this error multiple times
|
||||
elif(c == '\t'):
|
||||
continue
|
||||
elif(lineStart):
|
||||
lineStart = False
|
||||
else:
|
||||
continue
|
||||
if(fails != 0):
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
@ -22,7 +22,7 @@ pub const QuadInfo = extern struct {
|
||||
};
|
||||
|
||||
fn approxEqAbs(x: Vec3f, y: Vec3f, tolerance: Vec3f) @Vector(3, bool) {
|
||||
return @abs(x - y) <= tolerance;
|
||||
return @abs(x - y) <= tolerance;
|
||||
}
|
||||
|
||||
pub const Model = struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user