• What Do You Need Help With? V6
    7,544 replies, posted
Crashing with what exception?
[QUOTE=ZeekyHBomb;40342678]Crashing with what exception?[/QUOTE] [CODE] //Make a CSV file public void createCSV(int howManyCSVS, string fileName, int versionNumber) { //filePath = @"C:\Users\Dave\Desktop\" + fileName + ".csv"; List<string[]> cvrFirstTwoLines = new List<string[]>(); List<Movement> movementList = new List<Movement>(); Movement movement = new Movement(); string delimiter = ","; movementList = movement.fillCVR(howManyCSVS, versionNumber); cvrFirstTwoLines = movement.fillCVRFirstTwoLines(); //Join the trigger file contents with the movement list for (int i = 0; i < movementList.Count; i++) { cvrFirstTwoLines.Add(movementList[i].ConvertToStringArray()); } int length = cvrFirstTwoLines.Count; StringBuilder sb = new StringBuilder(); for (int index = 0; index < length; index++) { sb.AppendLine(string.Join(delimiter, cvrFirstTwoLines[index])); } File.WriteAllText(fileName, sb.ToString()); }[/CODE] It goes to that method and it says NotSupportedException was unhandled on the very last line with WriteAllText
That means that fileName does not point to a valid path. Probably because FileDialog.FileName describes a full path. Which makes sense actually. Do [code]saveFileDialog1.FileName = Path.Combine(Path.GetDirectoryName(saveFileDialog1.FileName), "test.", Path.GetFileName(saveFileDialog1.FileName));[/code] instead.
Thanks for that man. Was just told that I can have it be over writable so it's all good really appreciate the help buddy!
I need to swap two elements in a circular Doubly Linked List, can any1 provide me with some pseudocode, got some serious brainlags here
[QUOTE=lawli3t;40344249]I need to swap two elements in a circular Doubly Linked List, can any1 provide me with some pseudocode, got some serious brainlags here[/QUOTE] First element is A, second element is B store A's previous node and B's next node set A's next to the stored B next set A's previous to B set B's previous to the stored A previous set B's next to A
[QUOTE=robmaister12;40344417]First element is A, second element is B store A's previous node and B's next node set A's next to the stored B next set A's previous to B set B's previous to the stored A previous set B's next to A[/QUOTE] Doesn't that assume A and B are next to eachother? Isn't it as simple as swapping the two node's previous and next nodes? [code]tmpnext = A.next tmpprev = A.prev A.next = B.next A.prev = B.prev B.next = tmpnext B.prev = tmpprev[/code] [editline]19th April 2013[/editline] nevermind [editline]19th April 2013[/editline] I feel I may be overcomplicating it, but isn't it more like this: [code]A.prev.next = B A.next.prev = B B.prev.next = A B.next.prev = A temp_next = A.next temp_prev = A.prev A.next = B.next A.prev = B.prev B.next = temp_next B.prev = temp_prev[/code]
[QUOTE=MakeR;40344495]Doesn't that assume A and B are next to eachother? Isn't it as simple as swapping the two node's previous and next nodes? [code]tmpnext = A.next tmpprev = A.prev A.next = B.next A.prev = B.prev B.next = tmpnext B.prev = tmpprev[/code] [editline]19th April 2013[/editline] nevermind [editline]19th April 2013[/editline] I feel I may be overcomplicating it, but isn't it more like this: [code]A.prev.next = B A.next.prev = B B.prev.next = A B.next.prev = A temp_next = A.next temp_prev = A.prev A.next = B.next A.prev = B.prev B.next = temp_next B.prev = temp_prev[/code][/QUOTE] y, figured it out myself already, though you need to check if theyre next to each other, in which case another algorithm applies, so you both were right - thanks!
well i'm working with this big array of a student structure with each containing an array of classes [cpp] //sends each student one by one to the class sorter for (int i = 0; i < realSize; i++) { sort_class(studentArray[i]); } ... void sort_class (Student &singStudent) { Class proxClass; for (int ii = 1; ii < singStudent.numClasses; ii++) { if (singStudent.classes[ii-1].title > singStudent.classes[ii].title) { proxClass = singStudent.classes[ii]; singStudent.classes[ii] = singStudent.classes[ii-1]; singStudent.classes[ii-1] = proxClass; } } } [/cpp] (ignore the ii when i should have used i, leftover from passing the entire array) but basically it only gets like halfway through sorting the classes. If i put in (Z, B, Y, A) as the 4 classes, it sorts it to (B, Y, A, Z), so it's obviously moving things around, but isn't quite finishing. [editline]19th April 2013[/editline] Second problem is that since I'm a stubborn bastard who wanted to sort by last names, my binary search for names isn't working. since i only sorted by the last names, and the first names would be in a random order (didn't know how to then sort by first names), I couldn't binary search after finding the last name. That doesn't seem to be a big problem though because it doesn't even find any matching last names. [url]http://pastebin.com/7xnDnvVb[/url] --main and the name search function + the structs
That is one bubblesort-pass. You need to repeat that until no entries were swapped.
alright that's problem one solved. Problem two is the pastebin link
If I want to return two things throw a C# function to Lua and make the functions arguments the things being returned by C# how would I do so? An example on the Lua side would be: [lua] function PlayerSay(speakerName, speakerSays) print("["..speakerName.."]: "..speakerSays) end [/lua] So basically how do I pass those things through C#
Gotta post my swapping problem again. Still want to swap two circular doubly linked list elements, in the a.prev == b section there seems to be an error, i cant find... [CODE] public void SwapListElements(ListElement a, ListElement b, DoublyLinkedList in){ if (a.next == b) { if (a == in.first) { in.first = b; } if(b == in.first){ in.first = a; } a.prev.next = b; b.next.prev = a; a.next = b.next; b.prev = a.prev; a.prev = b; b.next = a; } else if (a.prev == b) { if(b == in.first){ in.first = a; } if (a == in.first) { in.first = b; } b.prev.next = a; a.next.prev = b; b.next = a.next; a.prev = b.prev; b.prev = a; a.next = b; } else{ a.prev.next = b; a.next.prev = b; b.prev.next = a; b.next.prev = a; ListElement temp1 = a.next; ListElement temp2 = a.prev; a.next = b.next; a.prev = b.prev; b.next = temp1; b.prev = temp2; } }[/CODE]
I just can't get my colision working ._. My think cycle: [code]private void Think() { while (_window.IsOpen()) { Thread.Sleep(10); _player.Ticks++; HandleInput(); //_player.Velocity += new Vector2f(0, Settings.Gravity); foreach (Tiles.ITile tile in _tiles) tile.DoColision(_player); _player.Position += _player.Velocity; } }[/code] My DoColision function (for a solid block): [code]public void DoColision(Player player) { Sprite pSprite = player.Sprite; FloatRect pRect = new FloatRect(player.Position.X + player.Velocity.X, player.Position.Y + player.Velocity.Y, pSprite.TextureRect.Width * Settings.Scale, pSprite.TextureRect.Height * Settings.Scale); FloatRect tRect = new FloatRect(Sprite.Position.X, Sprite.Position.Y, Sprite.TextureRect.Width * Settings.Scale, Sprite.TextureRect.Height * Settings.Scale); if (!pRect.Intersects(tRect)) return; if (pSprite.Position.X + player.Velocity.X + (pSprite.TextureRect.Width * Settings.Scale) > Sprite.Position.X && pSprite.Position.X + (pSprite.TextureRect.Width * Settings.Scale) < Sprite.Position.X) { Console.WriteLine("Player Left colide!"); player.Velocity = new Vector2f(pSprite.Position.X + (pSprite.TextureRect.Width * Settings.Scale) + player.Velocity.X - Sprite.Position.X, player.Velocity.Y); } else if (pSprite.Position.X + player.Velocity.X < Sprite.Position.X + (Sprite.TextureRect.Width * Settings.Scale) && pSprite.Position.X > Sprite.Position.X + (Sprite.TextureRect.Width * Settings.Scale)) { Console.WriteLine("Player Right colide!"); player.Velocity = new Vector2f(Math.Abs(pSprite.Position.X + player.Velocity.X - Sprite.Position.X - (Sprite.TextureRect.Width * Settings.Scale)), player.Velocity.Y); } }[/code] The current result is the the waling from right to left is detected but you just walk through it and the right to left doesn't work at all.
[url]http://pastebin.com/3sfDADEs[/url] my final function (highlow) is supposed to get a gpa to display all students with less than that gpa, and get a gpa to display all students with a greater gpa, mine just prints no students with less, and all are considered greater
[QUOTE=account;40332588]It doesn't have to part of any class, it could be in a util.cpp file or something[/QUOTE] I can't believe it took thousands of posts of back and forth before someone realized this. It's C++. You don't *need* to put it in any class at all, you just put it in a file and be done with it.
[QUOTE=LordCrypto;40348105]alright that's problem one solved. Problem two is the pastebin link[/QUOTE] The logic looks about right (apart from the infinite loop if the last name is not present in the array). Step through the code with a debugger to see where things start to go wrong. And you can easily access an out-of-bounds element in the second, full-name loop. Also, you could sort by the full name if you swap the first and last name and use the full name when sorting. [QUOTE=jrj996;40348279]If I want to return two things throw a C# function to Lua and make the functions arguments the things being returned by C# how would I do so? An example on the Lua side would be: [lua] function PlayerSay(speakerName, speakerSays) print("["..speakerName.."]: "..speakerSays) end [/lua] So basically how do I pass those things through C#[/QUOTE] Bind a LuaFunction (constructed with a C# function) to a Lua-variable, then you can access it from the Lua side. You can also load .NET libraries via luanet.load_assembly and access types via luanet.import_type. I haven't read any more specific stuff yet, but I suggest you take a look at the documentation and public API code for luainterface. [QUOTE=lawli3t;40349328]Gotta post my swapping problem again. Still want to swap two circular doubly linked list elements, in the a.prev == b section there seems to be an error, i cant find... [/QUOTE] "An error" is not very descriptive. I haven't checked the logic yet, but I can spot a few potential null-accesses, namely when {a,b}.{next,prev} are null (due to being at the start/end of the list). [editline]20th April 2013[/editline] [QUOTE=LordCrypto;40352146][url]http://pastebin.com/3sfDADEs[/url] my final function (highlow) is supposed to get a gpa to display all students with less than that gpa, and get a gpa to display all students with a greater gpa, mine just prints no students with less, and all are considered greater[/QUOTE] You are sorting by gpa in descending order, but expect it to be sorted in ascending order for highlow (I think). Could that also be why your binary search for names is not working?
i have to make a program that takes MD5 or SHA1 coded word as an argument and then finds the right word with brute force attack, meaning that it tries all combinations of letters codes them and compares them to the given one. I also know the length of the word and the type of the coding. Can somebody help me
[QUOTE=gparent;40352913]I can't believe it took thousands of posts of back and forth before someone realized this. It's C++. You don't *need* to put it in any class at all, you just put it in a file and be done with it.[/QUOTE] I'm a Java guy, sorry :v:
[QUOTE=RandomDexter;40355059]i have to make a program that takes MD5 or SHA1 coded word as an argument and then finds the right word with brute force attack, meaning that it tries all combinations of letters codes them and compares them to the given one. I also know the length of the word and the type of the coding. Can somebody help me[/QUOTE] What do you mean by "type of the coding"? The set of characters allowed? And what specifically do you need help with?
[QUOTE=ZeekyHBomb;40355153]What do you mean by "type of the coding"? The set of characters allowed? And what specifically do you need help with?[/QUOTE] if it's MD5 or Sha1. With the recursion method that generates words and with checking what code does generated word have(does it suit the given)
[QUOTE=RandomDexter;40355401]the recursion method that generates words[/QUOTE] Assuming original word contains alphanumeric characters start with a word of all 0's, increment until you hit '9', jump to 'A', increment until you hit 'Z', jump to 'a', increment until you hit 'z'. At that point you revert to '0' and increment the next character with the same rules. If there is no next character, then no word generates that hash-value. [QUOTE=RandomDexter;40355401]checking what code does generated word have(does it suit the given)[/QUOTE] I'm afraid I did not understand that. Could you rephrase? Are you asking how to compare the hash-values? If your language/framework does not allow direct equality comparison with hash-values see if you can get an array of integers or string-representation and compare bit by bit (pun intended).
[QUOTE=ZeekyHBomb;40354040]The logic looks about right (apart from the infinite loop if the last name is not present in the array). Step through the code with a debugger to see where things start to go wrong. And you can easily access an out-of-bounds element in the second, full-name loop. Also, you could sort by the full name if you swap the first and last name and use the full name when sorting. Bind a LuaFunction (constructed with a C# function) to a Lua-variable, then you can access it from the Lua side. You can also load .NET libraries via luanet.load_assembly and access types via luanet.import_type. I haven't read any more specific stuff yet, but I suggest you take a look at the documentation and public API code for luainterface. "An error" is not very descriptive. I haven't checked the logic yet, but I can spot a few potential null-accesses, namely when {a,b}.{next,prev} are null (due to being at the start/end of the list). [editline]20th April 2013[/editline] i fixed my names search You are sorting by gpa in descending order, but expect it to be sorted in ascending order for highlow (I think). Could that also be why your binary search for names is not working?[/QUOTE]
Trying to get freetype2 to work... [code]make [ 25%] Building CXX object CMakeFiles/tetragame.dir/src/main.cpp.o In file included from /home/tetra/Programming/Projects/Text Renderer (First Project)/src/text.hpp:5:0, from /home/tetra/Programming/Projects/Text Renderer (First Project)/src/window.hpp:7, from /home/tetra/Programming/Projects/Text Renderer (First Project)/src/main.cpp:1: /usr/include/ft2build.h:56:38: fatal error: freetype/config/ftheader.h: No such file or directory compilation terminated. make[2]: *** [CMakeFiles/tetragame.dir/src/main.cpp.o] Error 1 make[1]: *** [CMakeFiles/tetragame.dir/all] Error 2 make: *** [all] Error 2 [/code] CMakeLists.txt [code]cmake_minimum_required (VERSION 2.6) project ("Text Renderer") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") set( sources src/main.cpp src/window.cpp src/text.cpp src/loadshader.cpp ) add_executable("tetragame" ${sources}) find_package(GLFW REQUIRED) find_package(GLEW REQUIRED) find_package(GLM REQUIRED) include_directories(${GLFW_INCLUDE_DIR} ${GLEW_INCLUDE_PATH} ${GLM_INCLUDE_DIR} ${FREETYPE_INCLUDE_DIRS}) link_directories(${GLFW_LIBRARY_DIRS} ${GLM_LIBRARY_DIR} ${GLEW_LIBRARY} ${FREETYPE_LIBRARY}) target_link_libraries("tetragame" ${GLFW_LIBRARY} ${GLEW_LIBRARY} ${GLM_LIBRARY_DIR} ${FREETYPE_LIBRARIES}) [/code] FindFreeType.cmake [code]# - Locate FreeType library # This module defines # FREETYPE_LIBRARIES, the library to link against # FREETYPE_FOUND, if false, do not try to link to FREETYPE # FREETYPE_INCLUDE_DIRS, where to find headers. # This is the concatenation of the paths: # FREETYPE_INCLUDE_DIR_ft2build # FREETYPE_INCLUDE_DIR_freetype2 # # $FREETYPE_DIR is an environment variable that would # correspond to the ./configure --prefix=$FREETYPE_DIR # used in building FREETYPE. # Created by Eric Wing. # Modifications by Alexander Neundorf. # This file has been renamed to "FindFreetype.cmake" instead of the correct # "FindFreeType.cmake" in order to be compatible with the one from KDE4, Alex. # Ugh, FreeType seems to use some #include trickery which # makes this harder than it should be. It looks like they # put ft2build.h in a common/easier-to-find location which # then contains a #include to a more specific header in a # more specific location (#include <freetype/config/ftheader.h>). # Then from there, they need to set a bunch of #define's # so you can do something like: # #include FT_FREETYPE_H # Unfortunately, using CMake's mechanisms like INCLUDE_DIRECTORIES() # wants explicit full paths and this trickery doesn't work too well. # I'm going to attempt to cut out the middleman and hope # everything still works. FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h HINTS $ENV{FREETYPE_DIR} PATH_SUFFIXES include PATHS /usr/local/X11R6/include /usr/local/X11/include /usr/X11/include /sw/include /opt/local/include /usr/freeware/include ) FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h HINTS $ENV{FREETYPE_DIR}/include/freetype2 PATHS /usr/local/X11R6/include /usr/local/X11/include /usr/X11/include /sw/include /opt/local/include /usr/freeware/include PATH_SUFFIXES freetype2 ) FIND_LIBRARY(FREETYPE_LIBRARY NAMES freetype libfreetype freetype219 HINTS $ENV{FREETYPE_DIR} PATH_SUFFIXES lib64 lib PATHS /usr/local/X11R6 /usr/local/X11 /usr/X11 /sw /usr/freeware ) # set the user variables IF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2) SET(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}") ENDIF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2) SET(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}") # handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS) MARK_AS_ADVANCED(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build)[/code] please help
You seem to be missing the [code]find_package(FreeType REQUIRED)[/code]
Thanks man! That worked.
[QUOTE=ZeekyHBomb;40355590]Assuming original word contains alphanumeric characters start with a word of all 0's, increment until you hit '9', jump to 'A', increment until you hit 'Z', jump to 'a', increment until you hit 'z'. At that point you revert to '0' and increment the next character with the same rules. If there is no next character, then no word generates that hash-value. I'm afraid I did not understand that. Could you rephrase? Are you asking how to compare the hash-values? If your language/framework does not allow direct equality comparison with hash-values see if you can get an array of integers or string-representation and compare bit by bit (pun intended).[/QUOTE] Only small letters and numbers matter. Can you help me with this method, i have problems with recursion Yes, comparing hash values. I'm working in java
Imma start with giving you a few pointers, so you might be able to figure it out by yourself. Using a StringBuilder will make it easier to modify the current brute-forced word, so use that. To generate the hash, do wordBuilder.toString().getBytes() and pass the result to the MessageDigest instance. Create the StringBuilder with the [url=http://docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html#StringBuilder(int)]StringBuilder(int capacity)[/url] constructor and pass in the length of the original word. Loop wordBuilder.capacity() times and append 0's. For the increment-logic, create a function taking the StringBuilder and an index. When calling it non-recursively the index should be 0, so it starts at the first character. There you just get the char at the index, increment it, check if it's greater than '9', if so jump to 'a'. If it's greater than 'z' you set the character to '0' and let the function call itself with index + 1, so it takes care of the next character. You're done then, so return. If the character was not greater than 'z' you'll want to set the char at the index to your incremented value and return. You might want to check if the index is greater than the length of the word (at the start of the function, before trying to access a char out of bounds); in that case, you've already tried all possible combinations. To compare the hash values, use [url=http://docs.oracle.com/javase/7/docs/api/java/security/MessageDigest.html#isEqual(byte[%5D, byte[%5D)]MessageDigest.isEqual(a,b);[/url].
Getting some shader errors: [code]Loading glyph set and shaders... Compiling shader textshader.vs... 0:1(1): error: syntax error, unexpected $end Compiling shader textshader.fs... 0:1(1): error: syntax error, unexpected $end [/code] Here's my loadshader.cpp [code]#include "loadshader.hpp" GLuint loadShader(const char* vertexpath, const char* fragmentpath) { GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER); GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER); std::string vertexCode; std::ifstream vertexStream(vertexpath, std::ios::in); if(vertexStream.is_open()) { std::string Line = ""; while(getline(vertexStream, Line)) vertexCode += "\n" + Line; vertexStream.close(); } std::string fragmentCode; std::ifstream fragmentStream(fragmentpath, std::ios::in); if(fragmentStream.is_open()) { std::string Line = ""; while(getline(fragmentStream, Line)) fragmentCode += "\n" + Line; fragmentStream.close(); } GLint Result = GL_FALSE; int InfoLogLength; printf("Compiling shader %s...\n", vertexpath); char const* vertexSourcePointer = vertexCode.c_str(); glShaderSource(VertexShaderID, 1, &vertexSourcePointer, NULL); glCompileShader(VertexShaderID); glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result); glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength); std::vector<char> VertexShaderErrorMessage(InfoLogLength); glGetShaderInfoLog(VertexShaderID, InfoLogLength, NULL, &VertexShaderErrorMessage[0]); printf("%s\n", &VertexShaderErrorMessage[0]); printf("Compiling shader %s...\n", fragmentpath); char const* fragmentSourcePointer = fragmentCode.c_str(); glShaderSource(FragmentShaderID, 1, &fragmentSourcePointer, NULL); glCompileShader(FragmentShaderID); glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result); glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength); std::vector<char> FragmentShaderErrorMessage(InfoLogLength); glGetShaderInfoLog(FragmentShaderID, InfoLogLength, NULL, &FragmentShaderErrorMessage[0]); printf("%s\n", &FragmentShaderErrorMessage[0]); printf("Linking program...\n"); GLuint ProgramID = glCreateProgram(); glAttachShader(ProgramID, VertexShaderID); glAttachShader(ProgramID, FragmentShaderID); glLinkProgram(ProgramID); glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result); glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength); std::vector<char> ProgramErrorMessage(std::max(InfoLogLength, int(1))); glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, &ProgramErrorMessage[0]); printf("%s\n", &ProgramErrorMessage[0]); glDeleteShader(VertexShaderID); glDeleteShader(FragmentShaderID); return ProgramID; }[/code] Basic text shaders: [code]#version 120 varying vec2 texcoord; uniform sampler2d tex; uniform vec4 color; void main() { gl_FragColor = vec4(1, 1, 1, texture2D(tex,texcoord).a) * color; } [/code] [code]#version 120 attribute vec4 coord; varying vec2 texcoord; void main() { gl_Position = vec4(coord.xy, 0, 1); texcoord = coord.zw; } [/code]
te[b]x[/b]tshader.{vs,fs} - seems like a typo. You should print an error if the file you're trying to load does not exist :)
Sorry, you need to Log In to post a reply to this thread.